in modules/frontend/app/modules/form/validator/unique.directive.js [43:72]
$onInit() {
const isNew = this.key && this.key.startsWith('new');
const shouldNotSkip = (item) => get(this.skip[0], item) !== get(...this.skip);
this.ngModel.$validators.igniteUnique = (value) => {
const matches = (item) => (this.key ? item[this.key] : item) === value;
if (!this.skip) {
// Return true in case if array not exist, array empty.
if (!this.items || !this.items.length)
return true;
const idx = this.items.findIndex(matches);
// In case of new element check all items.
if (isNew)
return idx < 0;
// Case for new component list editable.
const $index = this.listEditableTransclude
? this.listEditableTransclude.$index
: isNumber(this.$scope.$index) ? this.$scope.$index : void 0;
// Check for $index in case of editing in-place.
return (isNumber($index) && (idx < 0 || $index === idx));
}
// TODO: converge both branches, use $index as idKey
return !(this.items || []).filter(shouldNotSkip).some(matches);
};
}