Giter VIP home page Giter VIP logo

ember-validations's People

Contributors

erlichmen avatar gabesmed avatar kelonye avatar lcoq avatar lholmquist avatar qrilka avatar sohara avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-validations's Issues

Allow validators to receive function as option

With the NumericalityValidator, for example, the following code should works:

App.Pub = Ember.Object.extend(Ember.Validations, {
  totalCount: 12,
  validations: {
    bars: { 
      lessThan: function() {
        return this.get('totalCount');
      }
  }
});

Getting "TypeError: this.parentController.childControllers is undefined" when setting itemController on each helper

In my app I needed to set itemController for #each helper and when I did that ember-validations cause js issue. To give some more context to the problem: http://stackoverflow.com/questions/20529723/controller-support-for-nested-model-data

Here is a jsbin link to demonstrate the issue:
http://jsbin.com/UROCObi/5/

I couldn't find cdnjs link to ember-validations so have pasted in whole lib there. Please have a look, you probably have better grasp of this issue and the reason behind it.

Thanks,
Dee

EDIT:
Sorry issued issue in wrong place, the ember validation I was using was taken from here : https://github.com/dockyard/ember-builds

If possible please delete this issue, because I couldn't delete it!

Allow error message to be customized declaratively

Apart from explicitly overriding the message with the right key, i didn't see anywhere in the source code to declaratively add custom error message

Ember.ValidationError.addMessage('blank', "can't be blank");

vs

foo {
presence: true
message: "This is a required field"
}

Should numericality validator require presence of property?

Hi there,
I've run into an issue where I'd like to validator to ensure the numericality of a property only if it is present? Right now the validator is invalidating the model if e.g. a blank string (as in filling a form) is assigned to property. Shouldn't the numericality validator first ensure the property is not blank and only then add the 'notNumber' error message for that property?

If you agree, I can submit a pull request, but I thought I'd ask first.
Thanks,
Sean

dist file in the repository

This is such a cool library! ๐Ÿ‘

Except, I don't think everyone is using Rake. Well, at least I don't and therefore can't try it :(

Is there a chance you could keep a dist version in the repository?

Rewrite README

The README is almost completely written in code markup.
It's not pleasant-looking.

Uncaught TypeError: Object [object Object] has no method 'validate'

Unfortunately I couldn't create a working example with your tutorial because Ember.Object.extend does not work, is it outdated?

So I have the following:

App.User = DS.Model.extend(Ember.Validations, {
    validations: {
        firstname: {
            presence: true
        }
   }
}

My Controller which handles the user object which is created by user input (form elements):

App.IndexController = Ember.Controller.extend({
    actions: {
        register: function(){
            var user = this.get('model');
            user.validate();
       }
    }
});

At that moment I get the error: Uncaught TypeError: Object [object Object] has no method 'validate'
What have I done wrong? Bug? Thx for help.

For your information, why Ember.Object.extend does not work, I get the following error then:

Assertion failed: Expected hash or Mixin instance, got [object Undefined] ember.js:394
DEPRECATION: Action handlers contained in an `events` object are deprecated in favor of putting them in an `actions` object (error on <App.ApplicationRoute:ember230>)
        at Object.triggerEvent (http://localhost:9000/bower_components/ember/ember.js:30519:13)
        at trigger (http://localhost:9000/bower_components/ember/ember.js:29641:16)
        at handleError (http://localhost:9000/bower_components/ember/ember.js:29903:9)
        at invokeCallback (http://localhost:9000/bower_components/ember/ember.js:8055:19)
        at null.<anonymous> (http://localhost:9000/bower_components/ember/ember.js:8109:11)
        at EventTarget.trigger (http://localhost:9000/bower_components/ember/ember.js:7878:22)
        at http://localhost:9000/bower_components/ember/ember.js:8180:17
        at Object.DeferredActionQueues.flush (http://localhost:9000/bower_components/ember/ember.js:5459:24)
        at Object.Backburner.end (http://localhost:9000/bower_components/ember/ember.js:5545:27) 

Monitoring errors changes

Hi, I want to create a tooltips property that would contain processed error data from corresponding validators (key to key mapping). For that, I need to listen to any change in validation errors and update my tooltips hash.

The first thing I tried was attaching directly to the .errors property on the model. However, I don't get notifications when its error arrays change and there is no equivalent to @each for properties (barring some hacks I found online).

Then I tried attaching to some variation of validators.@each construct. Unfortunately, I would need [email protected].@each and that's a bit further than Ember allows.

Do you have any idea what I could attach or listen to? Some kind of global allErrors property would be ideal for this, but I would take anything at this point.

Allow automatic validation

It could be a good feature to have an option which make the validation automatically by listening each property that needs to be validated

Example with Template

I am just starting to use Ember and ember-validations. It would be helpful if you could provide an example of how validations are used in a template to provide visual feedback.

Validation scopes

It would be really useful if the library offered the ability to specify scopes for a particular set of validations.

Example:

App.User = Ember.Object.extend(Ember.Validations, {
  validations: {
    scope: {
      login: {
        password: {
          presence: true
        }
      }
      editProfile: {
        password: {
          presence: true
        }
        passwordConfirmation: {
          presence: true
        }
      }
    }
    // Normal, unscoped validations, which always applies.
    name: {
      presence: true
    }    
  }
});

And then you validate the model like so:

var user = App.User.create({
  username: 'user',
  password: 'password',
  passwordConfirmation: null
});

user.validate(); // true
user.validate('login'); // true
user.validate('editProfile'); // false

I grant that the example is not very plausible (one would not store a password in a model) but it does illustrate the general idea.

Allow defining validations at runtime

We'd like to define validations dynamically.. something like this:

 validations: (->    
     if @get 'required'
       value:
          presence: true
 ).property 'required'

But if validations is defined as a computed property it's always empty (overridden by mixin somehow??)

isValid on individual properties

Maybe im missing something obvious that is already available, but I'd like to bind to the validity of each property.

For example, to add an error class to a text field:

{{view Ember.TextField valueBinding="content.username" classNameBinding="content.validationErrors.username.isValid::error}}

Thanks, and great work!

Custom validation function never returns true in model.validate()

Trying to use a custom validate function:

validations: {
  password: {
    presence: true,
    length: {
      minimum: 6
    },
    format: {
      validator: function (object, attribute, value) {
        if (!Balanced.Utils.isValidPassword(value)) {
          object.set('hasError', true);
          return false;
        }
      }
    }
 }

}

But this is returning false every-time I call model.validate() even though I confirm that Balanced.Utils.isValidPassword() is returning true. What is the right way to do this?

Support to return upon first error

Would it be possible to exit validation execution upon first error instead of executing all the registered validations of an attribute, as in some scenarios it is not required to show all the messages of an attribute in one go like scenarios where error messages are displayed next to the input control inline, please correct me if this kind of support is already present and your contribution to this framework is very much appreciated.

Match 2 fields

A typical scenario where are registering for something and have to enter your password or email address and then re enter to confirm

i'm close to having something. needed for a current project

Use specific namespace

We should not add objects in Ember namespace directly.
A new namespace should be created.

dont assume that record is valid on createRecord() with no values passed

item = @store.createRecord 'item'
# ...
item.get('isValid') # true
# item.save() #oops tries to save even if validation fails

# try to set isValid explicitly
item = @store.createRecord 'item'
item.set 'isValid', false

# now even validateProperty() passes, isValid on record is not updated

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.