Sha256: e85d2872b221b79110829b35fa28482b8467a5b4739b95876e1ee4a28e46f53c

Contents?: true

Size: 1 KB

Versions: 28

Compression:

Stored size: 1 KB

Contents

# TODO Add base settings to validation
# model = window.model
# TODO implement method

# model[resource].validators_on 'field' # Get all validators related to this field

stampit     = require '../../../vendor/stampit'

associationable = stampit
  validate_each: (record, attribute, value) ->
    # TODO figure out why this method is being called twice
    if record[attribute]

      # TODO detect association type, and then validate
      # current we only support has_one associations
      unless 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  ->
        if record[attribute].errors.length
          record.errors.add attribute, 'associated', @options

      associated_validation


composed = stampit.compose(require('./validatorable'), associationable)
composed.definition_key = 'validates_associated'
module.exports = composed

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ende-0.4.25 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.24 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.23 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.5.1 components/indefinido/indemma/master/src/lib/record/validations/associated.coffee
ende-0.4.22 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.21 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.5.0 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.20 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.19 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.18 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.17 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.16 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.15 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.14 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.13 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.12 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.11 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.10 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.9 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee
ende-0.4.8 vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee