Skip to content

Commit

Permalink
Replace private and deprecated _lookupFactory with public & perform…
Browse files Browse the repository at this point in the history
…ant `factoryFor`
  • Loading branch information
cibernox committed Jan 24, 2017
1 parent 429647e commit 6a99cb8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion addon/validations/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,13 @@ function createValidatorsFor(attribute, model) {
* @return {Class} Validator class or undefined if not found
*/
function lookupValidator(owner, type) {
let validatorClass = owner._lookupFactory(`validator:${type}`);
let validatorClass;
if (owner.factoryFor) {
let maybeValidatorClass = owner.factoryFor(`validator:${type}`);
validatorClass = maybeValidatorClass && maybeValidatorClass.class;
} else {
validatorClass = owner._lookupFactory(`validator:${type}`);
}

if (isNone(validatorClass)) {
throw new Error(`[ember-cp-validations] Validator not found of type: ${type}.`);
Expand Down
7 changes: 6 additions & 1 deletion addon/validators/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ const Base = Ember.Object.extend({

if (!isNone(owner)) {
// Since default error messages are stored in app/validators/messages, we have to look it up via the owner
errorMessages = owner._lookupFactory('validator:messages');
if (owner.factoryFor) {
let maybeErrorMessages = owner.factoryFor('validator:messages');
errorMessages = maybeErrorMessages && maybeErrorMessages.class;
} else {
errorMessages = owner._lookupFactory('validator:messages');
}
}

// If for some reason, we can't find the messages object (i.e. unit tests), use default
Expand Down

0 comments on commit 6a99cb8

Please sign in to comment.