Sha256: 9a119e303d0be6f5cb6c3861bd7b268b93e11245e884776c25001f20c42ca2e0

Contents?: true

Size: 932 Bytes

Versions: 59

Compression:

Stored size: 932 Bytes

Contents

var associationable, composed, stampit, validations;

validations = require('../validatable');

stampit = require('../../../vendor/stampit');

associationable = stampit({
  validate_each: function(record, attribute, value) {
    var associated_validation;

    if (record[attribute]) {
      if (model[record.resource].has_one.indexOf(attribute) === -1) {
        throw new Error('Only has_one associations are supported to validates_associated');
      }
      associated_validation = record[attribute].validate();
      associated_validation.done(function() {
        if (record[attribute].errors.length) {
          return record.errors.add(attribute, 'associated', this.options);
        }
      });
      return associated_validation;
    }
  }
});

composed = stampit.compose(validations.validatable, associationable);

composed.definition_key = 'validates_associated';

validations.manager.validators.association = composed;

Version data entries

59 entries across 46 versions & 1 rubygems

Version Path
ende-0.1.14 vendor/assets/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.14 vendor/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.13 vendor/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.13 vendor/assets/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.12 vendor/assets/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.12 vendor/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.11 vendor/assets/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.11 vendor/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.10 vendor/assets/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.10 vendor/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.9 vendor/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.9 vendor/assets/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.8 vendor/assets/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.8 vendor/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.7 vendor/assets/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.7 vendor/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.6 vendor/assets/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.6 vendor/components/indefinido-indemma/lib/record/validations/associated.js
ende-0.1.5 vendor/assets/components/indefinido-indemma/lib/record/validations/associated.js