validus
Take an iterable and ensure that the members match a set of constraints.
using
Lets say we have some account data from a form or API request:
const subject =type: "accounts"attributes:email: "kurtis+1@amazon.com"name: ""age: 24
Consider this list of validations for a new account:
const validations =email:"You must have an email":"You must be a Google Employee":"You can't have suffix address":name:"You must have a name":age:"You must have an age":"You must be older than 30":friends:"You must have at least one friend":
Now you add water:
subject
Which results in this payload:
email:"You must be a Google Employee""You can't have suffix address"name:"You must have a name"age:"You must be older than 30"friends:"You must have at least one friend"
You can also do partial validation, say for form inputs:
"email"subject
Which returns:
"You must be a Google Employee""You can't have suffix address"