Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: edd7be554f
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (27 sloc) 0.857 kB
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
Jump to Line
Something went wrong with that request. Please try again.