vaadin / proposal-for-vaadin-form

Small and fast framework-agnostic library for creating forms with Web Components
Apache License 2.0
9 stars 0 forks source link

Type-safe forms #17

Open vlukashov opened 5 years ago

vlukashov commented 5 years ago

The VaadinForm and VaadinFormField API have TypeScript type definitions that inclcude a type parameter to define the types of the form fields. That allows build-time type checking of all form-handling code.

import {VaadinForm} from '@vaadin/vaadin-form';
import {Order} from './entities/order';

const form = new VaadinForm<Order>();
form.value = new Order(); // type-checked

// form properties are based on the form entity type
form.username.validator = [...];