Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom validation should allow assigning dataPath value #130

Open
ronjunevaldoz opened this issue Sep 4, 2024 · 3 comments
Open

Custom validation should allow assigning dataPath value #130

ronjunevaldoz opened this issue Sep 4, 2024 · 3 comments

Comments

@ronjunevaldoz
Copy link

ronjunevaldoz commented Sep 4, 2024

Please see related issue: #35

image

Steps

addConstraint(dataPath = "confirmPassword") {}
// or automatically catch dataPath from field
CreateBasicAccountInput::confirmPassword required { 
  addConstraint("Passwords should match") {
       it.password == it.confirmPassword
  }
}

Actual

error :dataPath: "", message: "Passwords should match"

Expectations

error: dataPath: "confirmPassword", message: "Passwords should match"

@dhoepelman
Copy link
Collaborator

See #29

@ronjunevaldoz
Copy link
Author

ronjunevaldoz commented Sep 4, 2024

See #29

I didn't quite see if this shows the correct answer or is it a pending wip. This is not resolve on my end

@dhoepelman dhoepelman reopened this Sep 9, 2024
@dhoepelman
Copy link
Collaborator

With 0.7.0 and #86 the situation will improve a bit, but this could be better

Validation<CreateBasicAccountInput> {
  validate("confirmPassword", { it.password to it.confirmPassword }) {
    addConstraint("Passwords should match") {
       it.password == it.confirmPassword
    }
  }
}

The above will have the correct path, but ideally addConstraint or similar should allow setting this directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants