Form Data validation library
Note : Work in progress
letb=makeBoel();construles=[b.field('name').isRequired().minLength(5).maxLength(100),b.field('email').isEmail().isRequired(),]letres=b.validate(rules,formData)if(res.has_errors){//res.error_map[field_ame].message contains the error messageemail_error=res.error_map.email.message}b.field('age').isBetween(10,60).message("Age out of range").onlyWhen("paying_now==1"),/** Compare between fields */b.field('current_salary').isGreaterThan('prev_salary'),/** multiple fields at the same time */b.fields("name","email").areRequired().maxLength(100);// Fields name and email are required with maxlength 100 (for both fields)/** change/translate message templates for all validations */b.updateMessages({'Required':"{{field}} is required","MaxLength":"The input shouldn't exceed {{max_length}} characters"})