partial.js logo
Latest version
v1.3.1 (RC2)


Schema builder is helpful for model definitions. By the schema you can validate a model.

var builders = require('partial.js/builders');

// Example:
builder.schema('user', { firstname: 'string(40)', lastname: String, created: Date }, function(name) {
    if (name === 'created')
        return new Date();

// Why?

// Do you understand?


builders.default(name)builders.defaults(name)builders.prepare(name, model)builders.schema(name, definition, [defaults])builders.validation(name, definition)
return Object;

This function is an alias for builders.defaults().

return Object;

Create a default object by the schema.

builders.prepare(name, model);
return Object;

Prepare model by the schema. Properties which are not defined in schema will be removed. Long strings will be truncated by the schema definition.

builders.schema(name, definition, [defaults]);
return Object;

Create a schema. Schema supports joining others schemas.

builders.validation(name, definition);
return Object;

Create a schema validation.