Skip to content
This repository was archived by the owner on Jan 31, 2019. It is now read-only.

Commit 69e526c

Browse files
committed
fixed most of the failing tests - breaking api
1 parent 25277c7 commit 69e526c

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,9 @@ import Base from 'ember-validations/validators/base';
374374
import Ember from 'ember';
375375

376376
export default Base.extend({
377-
init: function() {
377+
pushDependentValidationKeys: function() {
378378
// this call is necessary, don't forget it!
379379
this._super();
380-
381380
this.dependentValidationKeys.pushObject(this.options.alsoWatch);
382381
},
383382
call: function() {
@@ -388,8 +387,8 @@ export default Base.extend({
388387
});
389388
```
390389

391-
The `init` function is given access to the `this.options` which is simply
392-
a POJO of the options passed to the validator.
390+
The `pushDependentValidationKeys` function is called during `init` and is given access
391+
to the `this.options` which is simply a POJO of the options passed to the validator.
393392
`dependentValidationKeys` is the collection of paths relative to
394393
`this.model` that will be observed for changes. If any changes occur on
395394
any given path the validator will automatically trigger.

addon/validators/base.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ export default Ember.Object.extend({
1212
unless: get(this, 'options.unless')
1313
};
1414
this.dependentValidationKeys.pushObject(this.property);
15-
this.pushConditionalDependentValidationKeys();
15+
// this.model.addObserver(this.property, this, this._validate);
16+
this.pushDependentValidationKeys();
1617
this.addObserversForDependentValidationKeys();
1718
},
1819
addObserversForDependentValidationKeys: function() {
1920
this.dependentValidationKeys.forEach(function(key) {
2021
this.model.addObserver(key, this, this._validate);
2122
}, this);
2223
},
23-
pushConditionalDependentValidationKeys: function() {
24+
pushDependentValidationKeys: function() {
2425
Ember.A(['if', 'unless']).forEach((conditionalKind) => {
2526
const conditional = this.conditionals[conditionalKind];
2627
if (typeof(conditional) === 'string' && typeof(this.model[conditional]) !== 'function') {

addon/validators/local/confirmation.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ export default Base.extend({
1010
this.originalProperty = this.property;
1111
this.property = this.property + 'Confirmation';
1212
this._super();
13-
this.dependentValidationKeys.pushObject(this.originalProperty);
1413
/*jshint expr:true*/
1514
if (this.options === true) {
1615
set(this, 'options', { attribute: this.originalProperty });
1716
set(this, 'options', { message: Messages.render('confirmation', this.options) });
1817
}
1918
},
19+
pushDependentValidationKeys: function () {
20+
this._super();
21+
this.dependentValidationKeys.pushObject(this.originalProperty);
22+
},
2023
call: function() {
2124
var original = get(this.model, this.originalProperty);
2225
var confirmation = get(this.model, this.property);

0 commit comments

Comments
 (0)