Skip to content

Repository files navigation

BoelJS

Form Data validation library

Note : Work in progress

Usage

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}

Validate conditionally

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'),

Shortcut for validating multiple fields, same validations

/** 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)

Customize/Translate Error message templates

/** change/translate message templates for all validations */b.updateMessages({'Required':"{{field}} is required","MaxLength":"The input shouldn't exceed {{max_length}} characters"})

About

Form Data validation library

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages