Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: handle change method #58

Merged
merged 8 commits into from
Jan 18, 2021
Merged

feat: handle change method #58

merged 8 commits into from
Jan 18, 2021

Conversation

mixvar
Copy link
Collaborator

@mixvar mixvar commented Jan 12, 2021

  • add FieldHandle.handleChange which attempts to extract value out of change events for convenience.
  • remove instanceOf decoder in favour of date decoder
  • change decoders behaviour from strict to type coercion

closes #49

@mixvar mixvar requested a review from pidkopajo January 12, 2021 22:23
return Number.isFinite(value)
? { ok: true, value }
: { ok: false, value };
return Number.isFinite(value) ? { ok: true, value } : { ok: false };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, imho it's worth mentioning in docs, what values/types are accepted, as the area wider than finite numbers only
same for the rest of the decoders

Copy link
Collaborator Author

@mixvar mixvar Jan 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

each decoder has jsdoc attached to it, check them out :)

for number there is:

/**
 * Define field of type `number | ""` (empty string is needed to represent state of empty number inputs)
 * Does not accept infinite numbers: `Infinity`, `-Infinity`, `NaN`.
 * Default initial value will be `""`.
 *
 * @example
 * ```
 * const Schema = createForm.schema(fields => ({
 *   x: fields.number() // x: number | ""
 * }));
 * ```
 */

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsdoc improved

@mixvar mixvar merged commit a013729 into master Jan 18, 2021
@mixvar mixvar deleted the feat/handle-change-method branch January 18, 2021 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FieldHandle.handleChange function
2 participants