Ember Attrs Validations
Gone are the days where you forgot to pass an attribute from a parent to a child component. This addon will throw an error only in your test runs whenever a required attribute is undefined.
Compatibility
Supports Ember CLI v2.4 LTS.
I'm planning to support only the latest LTS versions of Ember. I won't be doing tests for any versions other than that.
Usage
Currently only supports validations for required fields and data type.
;; const Component } = Ember; ;
To see what types are available, see Ember.typeOf.
Caveat
When your data is async, the isRequired
will fail since the data originally will be undefined
until it resolves and passes the correct value.
Current workarounds:
- Make sure async data resolves first before rendering component (e.g. use handlebar
if
helper). - Make
isRequired
to false since in essence, you're allowing the attr to be undefined if you use async.
I don't have any plans as of the moment to seemlessly support async data. I'm open to PRs if anyone has a good idea on how to handle it.
Installation
git clone
this repositorynpm install
bower install
Running
ember server
- Visit your app at http://localhost:4200.
Running Tests
npm test
(Runsember try:testall
to test your addon against multiple Ember versions)ember test
ember test --server
Building
ember build
For more information on using ember-cli, visit http://www.ember-cli.com/.