#62 Ember Changeset Validations

Emad Ibrahim
Aug 24, 2016 · 1 min read

In the last tip, i talked about the awesome addon ember-changeset, there is a companion addon to add validations to your changeset.
Install the addon with

ember install ember-changeset-validations

Then you can wire up your model validator

changeset=(changeset user EmployeeValidations)
submit=(action "submit")
rollback=(action "rollback")

Then create your validator

// validations/employee.js
import {
} from 'ember-changeset-validations/validators';

export default {
firstName: [
validateLength({ min: 4 })
lastName: validatePresence(true),
email: validateFormat({ type: 'email' }),
password: validateLength({ min: 8 }),
passwordConfirmation: validateConfirmation({ on: 'password' })

Try it out and let me know how it works. Do you have a better way to handle validations?
ember-changeset-validations at https://github.com/DockYard/ember-changeset-validations
Ember Changeset Tip 61

Originally published at Ember Daily Tips.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store