Sha256: 8b122f9a8e95663d4ed2795978777f4aa9f139a85cecc04e48ca662c2498c5aa

Contents?: true

Size: 879 Bytes

Versions: 18

Compression:

Stored size: 879 Bytes

Contents

var associationable, composed, stampit;

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

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

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

composed = stampit.compose(require('./validatorable'), associationable);

composed.definition_key = 'validates_associated';

module.exports = composed;

Version data entries

18 entries across 18 versions & 1 rubygems

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