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

How to extend validators #4

Closed
ornolisvt opened this issue Aug 29, 2019 · 2 comments
Closed

How to extend validators #4

ornolisvt opened this issue Aug 29, 2019 · 2 comments

Comments

@ornolisvt
Copy link

I think that is a great library, but I would like to know how to implement a custom validator, for example, compare two fields for equality (password and repeat password)

@rcapraro
Copy link
Owner

Hi,
thank you for your interest in Kalidation.
Cross field validation is on the backlog for a future version of Kalidation.

In the meantime, you can use a function to validate the two password fields:

In your class:
fun validatePasswords(): Boolean = this.password == this.repeatPassword

And then in Kalidation

constraints<ClassWithMethods> {
    property(ClassWithMethods::xxxx) {
      ///
  }
    returnOf(ClassWithMethods::validatePasswords) {
        assertTrue()
  }

Hope this helps,.
Regards,
Richard

@rcapraro
Copy link
Owner

Closed

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