lib/plugins/validation.js
function (name) {
            this.__initValidation();
            var ret;
            if (isFunction(name)) {
                name.call(this, this.__getValidator.bind(this));
                ret = this;
            } else if (isString(name)) {
                ret = this.__getValidator(name);
            } else {
                throw new ModelError("name is must be a string or function when validating");
            }
            return ret;
        }
function (name) {
            this.__initValidation();
            var ret;
            if (isFunction(name)) {
                name.call(this, this.__getValidator.bind(this));
                ret = this;
            } else if (isString(name)) {
                ret = this.__getValidator(name);
            } else {
                throw new ModelError("name is must be a string or function when validating");
            }
            return ret;
        }
function ( name ) { this . __initValidation ( ) ; var ret ; if ( isFunction ( name ) ) { name . call ( this , this . __getValidator . bind ( this ) ) ; ret = this ; } else if ( isString ( name ) ) { ret = this . __getValidator ( name ) ; } else { throw new ModelError ( "name is must be a string or function when validating" ) ; } return ret ; }
Sets up validation for a model.

To do single col validation
{@code

var Model = patio.addModel("validator", {
plugins:[ValidatorPlugin]
});
//this ensures column assignment
Model.validate("col1").isDefined().isAlphaNumeric().hasLength(1, 10);
//col2 does not have to be assigned but if it is it must match /hello/ig.
Model.validate("col2").like(/hello/ig);
//Ensures that the emailAddress column is a valid email address.
Model.validate("emailAddress").isEmailAddress();
}

Or you can do a mass validation through a callback.
{@code

var Model = patio.addModel("validator", {
plugins:[ValidatorPlugin]
});
Model.validate(function(validate){
//this ensures column assignment
validate("col1").isDefined().isAlphaNumeric().hasLength(1, 10);
//col2 does not have to be assigned but if it is it must match /hello/ig.
validate("col2").isLike(/hello/ig);
//Ensures that the emailAddress column is a valid email address.
validate("emailAddress").isEmail();
});
}


@param {String|Function} name the name of the column, or a callback that accepts a function to create validators.

@throws {patio.ModelError} if name is not a function or string.
@return {patio.Model|Validator} returns a validator if name is a string, other wise returns this for chaining.
Sets up validation for a model .