Leda has a number of predefined validators both international and local.
Feel free to contact contributors to add another one you think can be useful for you or other people.
Another way to add a predefined validator is to make the job and send us a pull request.
Type | Description |
---|---|
type PredefinedValidator = | |
| 'creditCardNumber' | creditCardNumber uses a few algorithms including Luhn algorithm to check if it is a valid credit card number. |
| 'email' |
Also checks that no forbidden symbols are present |
| 'url' |
foo.com http:// Validation of non-latin characters is also supported. |
<> <L.Div _flex _mb-3> <L.Input form='commonValidators' name='creditCard' validator='creditCardNumber' invalidMessage={<i>Please enter a valid card number</i>} isRequired placeholder='card number' _w-48 _mr-3 /> <L.Input form='commonValidators' name='email' validator='email' invalidMessage={<i>Please enter a valid email</i>} isRequired placeholder='email' _w-48 _mr-3 /> <L.Input form='commonValidators' name='url' validator='url' invalidMessage={<i>Please enter a valid url</i>} placeholder='url' _w-48 _mr-3 /> </L.Div> <L.Button form='commonValidators' onValidationFail={({ invalidForms }) => log(invalidForms)} shouldScrollToInvalidFields scrollOffset={100} onClick={({ form }) => log(form)} > Submit </L.Button> </>