Sha256: a2ac0394eddea6a6617366e8d23e3d336efce06ae6868b9d6c872f6b4c40a816

Contents?: true

Size: 854 Bytes

Versions: 48

Compression:

Stored size: 854 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(require('./validatorable'), typeable);

composed.definition_key = 'validates_type_of';

module.exports = composed;

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
ende-0.5.22 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.21 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.20 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.19 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.18 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.17 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.16 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.15 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.14 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.13 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.12 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.10 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.9 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.8 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.7 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.6 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.4.25 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.5.5 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.4 components/indefinido/indemma/master/lib/record/validations/type.js
ende-0.5.3 components/indefinido/indemma/master/lib/record/validations/type.js