Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Validators for Modella
JavaScript Makefile
branch: master
Failed to load latest commit information.
deps add instance validator
lib fix instance validator with modella types
test fix instance validator with modella types
.gitignore Switched to better project layout. Test coverage possible now
.travis.yml add travis Release 0.1.2
Makefile add makefile and mocha for tests add js syntax highlighting
component.json Release 0.1.2
index.js Bug fix for component. Version bump to 0.0.4

Modella Validators

Build Status

A plugin that provides a bunch of validators for modella.

Example Usage

var Person     = modella('Person').attr('name', { required: true }),
    validation = require('modella-validators');


Basic Validators


Verifies that a field is present.

var User = User.attr('username', {required: true});


Verifies that a field equals another field.

var User = User.attr('password')
               .attr('passwordConfirmation', { confirms: 'password' });


Checks that a field is of a given type

var User = User.attr('name', {type: 'string'});

In addition to string support for primitives, you can also pass in a constructor.

var User = User.attr('parent', { type: User });

Format Validators

Verify the value of a field against a regex pattern. modella-validators comes with a few regex strings built in under the formatStrings object.


Validates the field against the given regular expression

var User = User.attr('name', {format: /\w+ \w+/ });

Phone Number

Validates the field against a (North American) phone number format

var User = User.attr('phone', {format: 'phone' });

Email Address

Validates the field against a email address format

var User = User.attr('email', {format: 'email' });


Validates the field against a URL format

var User = User.attr('website', {format: 'url' });
Something went wrong with that request. Please try again.