logo dile-components dile-components

Form Validation

Dile Components validate your forms in the browser before the data reaches the server: required fields, impossible values and a complete set of rules (email, minLength, between, same, files, IBAN...), with live validation, messages in English and Spanish, and client and server errors shown in the same way.

Three layers, load only what you need

The first two layers come with @dile/ui. Add @dile/validation to the forms that need rules.

Fields with the required attribute must have a value, in any DileForm and in plain HTML forms.

Each field reports what only it can detect: an impossible date, an incomplete mask, an invalid phone number, a text that is not an amount...

More than 30 rules inspired by Laravel, custom and asynchronous rules, and live validation while the user types.

Try it

A form with DileFormValidation. Errors are checked as soon as you leave a field and disappear as soon as you fix them.

class SignupForm extends DileFormValidation(DileForm(LitElement)) {
  static validations = {
    email: 'email|maxLength:120',
    age: 'integer|between:18,120',
    password: 'minLength:8',
    password_confirmation: 'same:password',
  };
  // render() the fields with name="email", name="age"...
}

const { valid, errors } = await form.validate();

What you get

Guides and reference