add ability to handle equality rule by validate.js#2
add ability to handle equality rule by validate.js#2drselump14 wants to merge 2 commits intojwald1:masterfrom
Conversation
There was a problem hiding this comment.
Thanks @drselump14 for the PR. Line 55 and 62 needs to be changed to let
// changed some var names
validatejsParams(attributeName) {
const rule = this.rules[attributeName]
if (!rule) {
return
}
// const won't work
let { value } = this.attributes.get(attributeName)
const attributes = {
[attributeName]: value,
}
if (rule.equality) {
const otherAttributeName = rule.equality.attribute
// const won't work
let { value } = this.attributes.get(otherAttributeName)
attributes[otherAttributeName] = value
}
return [attributes, { [attributeName]: this.rules[attributeName] }]
}Also, I think that it should be added to the README that equality validation needs to be set in both fields. For example, password and password_confirmation, if it's only set on the password_confirmation field than the user can change the password field without getting an error.
|
Hello, thanks for your comment. I've updated the readme for the explanation of equality password validation. Regarding your advice:
|
Equality rule on validate.js requires the value of another attribute.
This PR adding ability to handle the equality rule.