1
老辦法:新Aurelia驗證!等於(expectedValue)
this.validator = this.validation.on(this)
.ensure('baseContent.RedirectFrom')
.isNotEmpty()
.ensure('baseContent.RedirectTo')
.isNotEmpty()
.isNotEqualTo(() => { return this.baseContent.RedirectFrom }, 'Redirect from');
});
isNotEquals似乎並沒有在新的驗證存在有一個equals(expectedValue)
我也考慮過做不過一個自定義的驗證元素掙扎,因爲它穿過'RedirectFrom'未定義。
ValidationRules.customRule('notEqualTo',
(value, obj, otherValue) => {
return value === null || value === undefined || value === '' || otherValue === null || otherValue === undefined || otherValue === ''|| value === otherValue;
},
"must not match");
.ensure('RedirectTo').required().satisfiesRule('notEqualTo', this.baseContent.RedirectFrom)
.ensure('RedirectTo').required().satisfiesRule('notEqualTo', this.RedirectFrom)
.ensure('RedirectTo').required().satisfiesRule('notEqualTo', RedirectFrom)
任何人都能看到我失蹤的任何東西?