Skip to content

Commit

Permalink
fill warnings property on the validations object
Browse files Browse the repository at this point in the history
  • Loading branch information
zidjian257 authored Sep 8, 2017
1 parent 817a0a8 commit ab1b493
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions addon/validations/result-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ export default Ember.ArrayProxy.extend({
* @readOnly
* @type {Array}
*/
warnings: computed('attribute', '_warningContent.@each.errors', cycleBreaker(function() {
return computeErrorCollection(get(this, 'attribute'), get(this, '_warningContent'));
warnings: computed('attribute', '_warningContent.@each.warnings', cycleBreaker(function() {
return computeErrorCollection(get(this, 'attribute'), get(this, '_warningContent'), "warnings");
})).readOnly(),

/**
Expand Down Expand Up @@ -350,10 +350,10 @@ export default Ember.ArrayProxy.extend({
})).readOnly(),

/**
* @property _contentValidations
* @type {Array}
* @private
*/
* @property _contentValidations
* @type {Array}
* @private
*/
_contentValidations: computed('content.@each._validations', function() {
return emberArray(compact(this.getEach('_validations')));
}).readOnly(),
Expand All @@ -380,8 +380,8 @@ export default Ember.ArrayProxy.extend({
_warningContent: computed.filterBy('content', 'isWarning', true).readOnly()
});

function computeErrorCollection(attribute, content = []) {
let errors = flatten(content.getEach('errors'));
function computeErrorCollection(attribute, content = [], errorProperty="errors") {
let errors = flatten(content.getEach(errorProperty));

errors = uniq(compact(errors));
errors.forEach((e) => {
Expand Down

0 comments on commit ab1b493

Please sign in to comment.