Giter Club home page Giter Club logo

Comments (9)

NullVoxPopuli avatar NullVoxPopuli commented on May 25, 2024 1

Oh! The validation probably needs too be on event-attenndance! I'll try that

On Thu, Apr 21, 2016, 11:04 AM Esteban Arango Medina <
[email protected]> wrote:

@NullVoxPopuli https://github.com/NullVoxPopuli Looking at your code.
Seems like the attendance model doesn't have the level relation, are you
using there an attendance or an event-attendance (which is the one with
the realtion) ?
The validation looks good and should be working as you have it there.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#32 (comment)

from ember-model-validator.

NullVoxPopuli avatar NullVoxPopuli commented on May 25, 2024

I have this currently:

        custom: {
          message: 'Level is required for the selected ticket.',
          // value may be a promise here
          // so we need to see if we can access the
          // id property on it
          validation(key, value, model){
            let requiresLevel = model.get('package.requiresTrack');
            debugger;
            if (requiresLevel){
              // value is undefined, and level is a promise
              return Ember.isPresent(model.get('level'));
            }

            return true;
          }
        }

from ember-model-validator.

esbanarango avatar esbanarango commented on May 25, 2024

@NullVoxPopuli You need to add that validation directly on the relation. Could you show me your entire model.

from ember-model-validator.

NullVoxPopuli avatar NullVoxPopuli commented on May 25, 2024

here is the model: https://github.com/NullVoxPopuli/aeonvera-ui/blob/master/app/models/attendance.js#L66

here is how I'm validating it: https://github.com/NullVoxPopuli/aeonvera-ui/blob/master/app/services/order-cart.js#L153

(I'm just calling validate() on the attendance)

from ember-model-validator.

esbanarango avatar esbanarango commented on May 25, 2024

@NullVoxPopuli Looking at your code. Seems like the attendance model doesn't have the level relation, are you using there an attendance or an event-attendance (which is the one with the realtion) ?
The validation looks good and should be working as you have it there.

from ember-model-validator.

esbanarango avatar esbanarango commented on May 25, 2024

@NullVoxPopuli Let me know if that works so I can close this issue. Thank you.

from ember-model-validator.

NullVoxPopuli avatar NullVoxPopuli commented on May 25, 2024

Ok, so I finally move the level validation to the event-attendance:

image

So maybe it's just a logic thing. Cause if I change my isPresent check to be on model.get('level.id'), it works just fine ('throws' a validation error via validate())

from ember-model-validator.

NullVoxPopuli avatar NullVoxPopuli commented on May 25, 2024

Though, I think it would be great to have bulit in if: keys on the relationship validators, like, I would like to do:

validations: {
  level: { 
    presence: true,
    if: 'model.package.requiresTrack'
  }
}

from ember-model-validator.

NullVoxPopuli avatar NullVoxPopuli commented on May 25, 2024

also, it appears validations get extended from superclass to subclass :-\ I'll open that as a seperate issue

from ember-model-validator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.