react-validator icon indicating copy to clipboard operation
react-validator copied to clipboard

a prop that allows you to have validator be active or off

Open sallyhill opened this issue 7 years ago • 3 comments

would be awesome to have a conditional expression on Validator component that alters whether validator is actively checking for and displaying errors

sallyhill avatar Feb 22 '17 17:02 sallyhill

I am not able to understand - "validator logs errors". You may use ref on Validation component, and then call isValid method to find if it is valid, and can alert in case its invalid. Or, your validator function is called every time the value changes, you can put alert there before return true/false.

vishalvisd avatar Feb 22 '17 18:02 vishalvisd

I'm not entirely sure how to temporarily stop a validator from being active without conditionally rendering the <Validator> component. You may have just answered this but I'm failing to understand. I have radio buttons and one is a custom input with validation. I only want validation errors to display on the input field if the radio button associated with custom is checked.

sallyhill avatar Feb 23 '17 20:02 sallyhill

You should be able to access radio button value in the validator function. If you don't want to display error simply return true, in case the checkbox is checked.

This can be added as a feature, where a prop can be used to disable validation conditionally.


Additionally, released 2.3.0. In your case if that something related to closure, please read the read me update.

vishalvisd avatar Feb 26 '17 03:02 vishalvisd