Rails style create and edit validations for models
JavaScript
Switch branches/tags
Nothing to show
Pull request Compare This branch is 14 commits behind learndot:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
tests
validators
Buildfile
README
core.js
validatable.js

README

Rails style model validation for Sproutcore Models.

USAGE:

var class = SC.Object.extend(ModelValidators.Validatable, {

    someProperty: 'Test',
    
    // validators
    validators: ['someProperty'],
    somePropertyValidator: ModelValidators.PresenceValidator

});


var object = class.create();
object.validate(); // returns true

object.set('someProperty', '');
object.validate(); // returns false
object.get('somePropertyError'); // You must enter a Some Property
object.get('someProeprtyIsInError'); // Used for driving CSS classes 

Feel free to fork and add any validators that you think might be valuable, or suggest ones you'd like and I'll fire em in there.

Current Validators:

Strings
    - Format (regexp)
    - Min Length
    - Length Range
    - Url Validator

Numbers
    - positive number

General
    - Equality
    - Presence


.joe