Skip to content

Commit

Permalink
Update has-many.js (#598)
Browse files Browse the repository at this point in the history
There was an issue with checking a hasMany for me, I'm not 100% sure on the exact circumstances but it was triggered after an upgrade to EmberJS 3.1+. Importing get, rather than assuming the object has the get method, fixed things nicely and is arguably a smart way to proceed anyway.
  • Loading branch information
JackEllis authored and offirgolan committed Jul 21, 2018
1 parent 30aea98 commit 3eb069e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion addon/validators/has-many.js
@@ -1,5 +1,6 @@
import Base from 'ember-cp-validations/validators/base';
import { isPromise } from 'ember-cp-validations/utils/utils';
import { get } from '@ember/object';

/**
* <i class="fa fa-hand-o-right" aria-hidden="true"></i> [See All Options](#method_validate)
Expand Down Expand Up @@ -55,7 +56,7 @@ const HasMany = Base.extend({
return value.then(models => this.validate(models, ...args));
}

return value.map(m => m.get('validations'));
return value.map(m => get(m, 'validations'));
}

return true;
Expand Down

0 comments on commit 3eb069e

Please sign in to comment.