validate
validate exports a few methods that help validating a value
import { validate } from chili-ui
or
import * as L from chili-uiL.validate.email('123@gmial.com')
Common validators
| Name | Type | Description |
|---|---|---|
| (email: string) => boolean | ... | |
| url | (url: string) => boolean | ... |
| creditCardNumber | (cardNumber: string) => boolean | ... |
() => { return ( <> <L.Button onClick={() => { const number = prompt('Enter a card number') const isValid = L.validate.creditCardNumber(number) const result = isValid ? 'valid' : 'not valid' alert('The card number is ' + result) }} > click to validate your card number * </L.Button> <p className='text-xs mt-4'> * It is safe, validation takes place on the frontend side only, no data are stored or trasferred anywhere. </p> </> ); }
