Application for Ember example with server-side validation processing

I am looking for an open source application or an Ember sample using Ember data that relies on an API and handles server-side validation.

I find it very difficult to find examples of a good standard way to handle server-side validation with Ember and Ember data.

+4
source share
1 answer

If your API returns validation errors with 422, similarly:

{"errors":{"email":["can't be blank"]}} 

then the easiest way to tell the user that something has not been confirmed properly is to place an error message next to the corresponding control in your template:

 {{view Ember.TextField id="email" placeholder="Email" valueBinding="email"}}<span class="alert-error">{{errors.email}}</span> 

If you want to skip errors and possibly show them to the user in a different way (I like notifications similar to growls in addition to the built-in messages), you can also capture them from object errors in the model in wasInvalid . Errors are also passed to wasInvalid if you want to capture them.

+4
source

Source: https://habr.com/ru/post/1489542/


All Articles