This is a JavaScript implementation of Schema-Woven Validation (SWV), the next generation of web form validation mechanism.
npm install @contactable/swv --save
import { validate } from '@contactable/swv';
// schema: SWV schema object
// formData: FormData object
const result = validate( schema, formData );
for ( const [ field, { error } ] of result ) {
if ( undefined !== error ) {
// Add validation error message to the field
}
}