Availity / availity-reactstrap-validation

Easy to use React validation components compatible for reactstrap.
https://availity.github.io/availity-reactstrap-validation/
MIT License
191 stars 70 forks source link

Using AvField correctly displays an invalid result, is it possible to display a valid? #181

Closed simonk83 closed 4 years ago

simonk83 commented 4 years ago

At the mo I’m using this:

<AvField name="name" label="Name (default error message)" type="text" errorMessage="Invalid name" validate={{ required: {value: true}, pattern: {value: '^[A-Za-z0-9]+$'}, minLength: {value: 6}, maxLength: {value: 16} }} /> It'll display the red outline and danger mark if the pattern doesn't match, which is great, but I'd also ideally like it to show the green outline and check mark when the pattern does match. Is that actually an option?

TheSharpieOne commented 4 years ago

No, it's not possible with AvField. AvField is opinionated to availity's opinion, which is showing only error feedback. classNames are applied to valid fields, with custom CSS you could add styles to match what you want. Keep in mind that a field is either valid or invalid, but there is probably a third state you want to account for: untouched. You don't want to show a valid or invalid state when the user hasn't done anything. Another option is to modify/override AvField's render in your code to account for showing the valid state.