Last active
June 17, 2017 14:57
-
-
Save blogui91/a49a8c28c4c1f5f6d509f664cbea2772 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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