How are people handling client side validation and ember?
Is there anything out of the box or a plugin that handles validation or are people just rolling their own?
The idea behind a changeset is simple: it represents a set of valid changes to be applied onto any Object ( Ember. Object , DS. Model , POJOs, etc).
https://github.com/dockyard/ember-validations might be useful. It also hooks up to Ember-easy-form
I would extend Ember.TextField (or whatever input type your validating) and use classBinding with a computed property. Here is the sample: http://jsfiddle.net/caligoanimus/7UNRd/
template:
<script type="text/x-handlebars" > {{view App.AlphaNumField placeholder="alpha-numeric data only" valueBinding="App.alphaNumInput"}} </script>
application:
App = Ember.Application.create({ AlphaNumField: Ember.TextField.extend({ isValid: function() { return /^[a-z0-9]+$/i.test(this.get('value')); }.property('value'), classNameBindings: 'isValid:valid:invalid' }) });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With