Skip to content

Instantly share code, notes, and snippets.

@blogui91
Last active June 17, 2017 14:57
Show Gist options
  • Save blogui91/a49a8c28c4c1f5f6d509f664cbea2772 to your computer and use it in GitHub Desktop.
Save blogui91/a49a8c28c4c1f5f6d509f664cbea2772 to your computer and use it in GitHub Desktop.
import Validator from 'laravalidator-js'
export class ClientValidator extends Validator
{
constructor(data) {
super()
this.rules = {
fullname: ['required'],
email: ['email'],
age: ['numeric', 'customvalidator']
};
this.data = data
this.messages = {
fullname: {
required: "fullname is required"
},
age: {
numeric: "This field must be numeric",
customvalidator: "Custom message"
}
}
this.extend({
customvalidator(value) {
//enter your validation here
return true
},
anothervalidator(value) {}
})
}
static make(data = {})
{
let validate = new ClientValidator(data);
return validate.exec()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment