DigitalRiver / react-atlas

Composable React components with CSS Modules.
http://digitalriver.github.io/react-atlas/
MIT License
38 stars 25 forks source link

Allow for custom error message when maxLength is reached. #712

Closed hbowden closed 6 years ago

hbowden commented 6 years ago

Currently with atlas if you have maxlength set and you reach the maxlength no error message is fired. Also if we have TextField and TextArea fire an error message when they reach maxLength, we need a prop or another mechanism to supply the maxLength message. If we use the default of "this field is required" it won't make sense. Finally we need to allow for a required message, a custom validation message and maxlength error messages to all be fired for those respective errors events, right now we only allow for a single error message to be set for our Input components.

Magneticmagnum commented 6 years ago

I disagree with putting multiple error messages as props on TextField component.

If multiple error messages are needed, it should be managed in your app and passed to the component through the errorText prop.

If you need the error message to fire when a max length is reached, the validator prop should be used.

hbowden commented 6 years ago

If we force the user to use validator if they want to display an error message for a character limit then there's no real reason to have a maxLength prop.

hbowden commented 6 years ago

Also the TextField component needs to inform the app which error happened so it can set the appropriate error message. As of right now there is no way to know what error happened.

stuller commented 6 years ago

we're using the maxLength prop for Checkout.js btw - for CVV and CC fields - we don't need an error for it, just need it to continue to get passed down to the html input for what we're doing.

ericsewalson commented 6 years ago

Text area includes a count if maxlength is used. There is no error needed as the visual treatment shows the max and actual lengths. Closing this issue.