I'm looking for an Ember open-source or sample app, using Ember-data, that is relying on an API and that handles server-side validation.
I have a very hard time finding examples of a good, standard way to handle server-side validation with Ember and Ember-data.
If your API returns validations errors with a 422, similar to:
{"errors":{"email":["can't be blank"]}}
then, the simplest way to let the user know something didn't validate properly, is to place the error message next to the appropriate control in your template:
{{view Ember.TextField id="email" placeholder="Email" valueBinding="email"}}<span class="alert-error">{{errors.email}}</span>
If you'd like to loop through the errors and maybe show them to the user in a different way (I like growl-like notifications in addition to inline messages), you can also grab them from the errors object on the model in the becameInvalid hook. The errors are also passed into the becameInvalid hook if you wanna grab them that way.
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