validate

validate exports a few methods that help validating a value

import { validate } from leda

or

import * as L from leda
L.validate.email('123@gmial.com')

Common validators

NameTypeDescription
email(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>
    </>
  );
}