question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Comparing password fields

See original GitHub issue

I am using class-validator to validate my incoming requests in an express application and I am very happy with it.

Currently I am implementing a registration service, my request has two password fields, password and password2. I would like to compare them to each other but it seems that this functionality is lacking in class-validator.

Is class-validator able to handle this scenario already or is this a feature request?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ChrLippcommented, Dec 23, 2016

IsLongerThan looks promising, I will try that. Thanks for your work!

Regards, Christian

0reactions
ChrLippcommented, Dec 26, 2016

Unfortunately this code doesn’t compile.

error TS2345: Argument of type '{ constraints: string[]; options: ValidationOptions | undefined; propertyName: string; target: Fu...' is not assignable to parameter of type 'ValidationDecoratorOptions'.
  Types of property 'options' are incompatible.
    Type 'ValidationOptions | undefined' is not assignable to type 'ValidatorOptions'.
      Type 'undefined' is not assignable to type 'ValidatorOptions'.

The version of typescript is

"typescript": "2.1.4",

It works when the second param is not optional.

export function IsEqualTo(property: string, validationOptions: ValidationOptions) {
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Comparing 2 password fields - MSDN - Microsoft
How to Comparing 2 password fields RRS feed ... a simple web page in which it has First name,Second name,Login id,Password and Confirm...
Read more >
Compare value in the password fields - Form
Compare value in the password fields : Password « Form « JavaScript Tutorial ; 10.10.3. Password.defaultValue ; 10.10.4. Password.focus() ; 10.10.5. Password.form.
Read more >
How to compare passwords in Javascript
I have a registration page and I want to compare two passwords (input fields) to be equal before writing it to a websql...
Read more >
Compare two field strings for passwords
I have the field for the new password reading the regular expressions fine. But for some reason the re-enter new password field is...
Read more >
Comparing two password fields for insertion into database
I have two form fields a 'password' and 'confirmpassword' field I just want to make sure the two text strings match.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found