Skip to content

Instantly share code, notes, and snippets.

@andevsoftware
Last active March 5, 2016 12:18
Show Gist options
  • Save andevsoftware/ee9318a85f96b449b86f to your computer and use it in GitHub Desktop.
Save andevsoftware/ee9318a85f96b449b86f to your computer and use it in GitHub Desktop.
TSValidate Introduction
import Email = TSValidate.Validators.Email;
import PresenceOf = TSValidate.Validators.PresenceOf;
var validation = new TSValidate.Validation;
validation.add(
'name',
new PresenceOf()
.message('The name is required')
);
validation.add(
'email',
new PresenceOf()
.message('The e-mail is required')
);
validation.add(
'email',
new PresenceOf()
.message('The e-mail is not valid')
);
var messages = validation.validate(data);
if (messages.count()) {
messages.each(message => {
console.log(message);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment