indexiatech / ember-forms

Smart, Intuitive forms for Ember.js styled with Bootstrap, Multi layouts and Validation support.
http://indexiatech.github.io/ember-forms
Apache License 2.0
218 stars 45 forks source link

Ember.Validations implementation is incorrect #72

Closed jackmatt2 closed 9 years ago

jackmatt2 commented 9 years ago

This library forces you to define the validations of the model for it to work. This is incorrect and the validations should actually be defined on the controller. The rationale around this is that for different screens, the same model may have different validation requirements. Defining them in the model forces all screens to use the same validation logic.

Can this be updated to use validations from the controller instead of the model?

export default Ember.Controller.extend(EmberValidations.Mixin, {
    validations: {
        name: {
            presence: true,
            length: { minimum: 5 }
        }
    },
}
jackmatt2 commented 9 years ago

Actually, passing

{{#em-form model=controller

instead of

{{#em-form model=model

works.

asaf commented 9 years ago

Yap :)