Ember Changeset CP Validations
Ember CP Validations support for Ember Changeset
Requirements
- ember-cp-validations v3.1.0 or above
- ember-changeset
Installation
ember install ember-changeset-cp-validations
Helpful Links
- ### Changelog
Looking for help?
If it is a bug please open an issue on GitHub.
Usage
The Template Helper
This addon updates the changeset
helper by creating a changeset instance via the createChangeset
.
{{dummy-form changeset=(changeset user) submit=(action "submit") rollback=(action "rollback")}}
Passing a custom action as a second argument to the changeset
helper is supported but make
sure to call the passed validate
method to run the necessary validations.
{{dummy-form changeset=(changeset user (action "customValidate")) submit=(action "submit") rollback=(action "rollback")}}
; const Component = Ember; ;
Creating a Changeset
There are 2 ways to create a changset programmatically.
Using createChangeset
createChangeset
is a no fuss way of quickly creating a new changeset instance.
It will return a new changeset instance that is setup for the passed model and its validations.
;; const Component = Ember; ;
Using buildChangeset
buildChangeset
allows you more freedom with creating the changeset instance.
It will return a hash that includes the validateFn
and validationMap
required to
support the validations for the passed model.
;; const Component = Ember; ;
Disable CP Validations Dependents
When changes get applied to the actual model, validations will be re-triggered since the dependents of the CPs have changed. As of ember-cp-validations v3.1.0, to disable this, you may put all or selective attribute CPs in a volatile state via the volatile option.
const Validations = ;