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

Version Path
ende-0.3.13 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.3.12 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.3.11 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.3.10 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.3.9 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.3.8 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.3.7 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.3.6 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.3.5 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.3.4 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.3.3 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.3.2 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.3.1 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.3.0 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.2.21 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.2.20 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.2.19 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.2.18 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.2.17 vendor/components/indefinido-indemma/lib/record/validations/type.js
ende-0.2.16 vendor/components/indefinido-indemma/lib/record/validations/type.js