Skip to content
This repository was archived by the owner on Nov 28, 2023. It is now read-only.

Conversation

samhinton88
Copy link
Collaborator

@samhinton88 samhinton88 commented Jun 18, 2021

JIRA

This adds a prop to inputProps that allows a client to pass a function with determines whether or not validation messages should be shown.

This seems to offer a good level of flexibility to clients who want to determine when to show visibility, whilst also maintaining raw validation state behind the scenes and allowing us to provide reasonable defaults.

The library comes with generic and onBlur functions. generic is used by default and will indicate that validation messages should be shown whenever the field is invalid.

An example function:

export const notWhenChanging: VisibilityCallback = ({ 
  validation: { valid }, 
  hadChanged, blurred
}) =>  !valid && blurred && !hadChanged

This could be achieved with top level state, but it seems cleaner to offer this field-level api.

Questions:

  • Should the inputState be available to the visibility callback? eg. on .parentState property or similar.

@samhinton88 samhinton88 requested a review from fenetic June 18, 2021 09:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant