Sha256: f5f2f79c2cf1fa34312756f239744fb112bd507be624c3aba34f4725568c45b3
Contents?: true
Size: 872 Bytes
Versions: 36
Compression:
Stored size: 872 Bytes
Contents
var composed, stampit, typeable, validations; validations = require('../validatable'); stampit = require('../../../vendor/stampit'); typeable = stampit({ validate_each: function(record, attribute, value) { this.type || (this.type = model[record.resource.toString()][attribute]); if (value) { if (value instanceof this.type) { this.type_name || (this.type_name = this.type.name); if (!value.valid) { return record.errors.add(attribute, 'type', { type_name: this.type_name != null }); } } else { throw new Error("Invalid attribute value type! Found " + (typeof value) + " expected " + this.type.name); } } } }); composed = stampit.compose(validations.validatable, typeable); composed.definition_key = 'validates_type_of'; validations.manager.validators.type = composed;
Version data entries
36 entries across 36 versions & 1 rubygems