-
Notifications
You must be signed in to change notification settings - Fork 767
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
question @Matches
decorator with my regex shows true sometimes while false sometimes
#484
Comments
@vlapo also when is the release of next version. I like to use the uuid fix |
I've also encountered this with Here's my user class: import {
IsEmail,
Matches,
IsOptional,
IsPhoneNumber,
IsDefined,
validateSync
} from "class-validator";
export class User {
@IsDefined()
@IsEmail()
public email: string;
@IsDefined()
@Matches(/[a-zA-Z0-9_-]{2,20}/)
public username: string;
@IsDefined()
@Matches(/^\$2[ayb]\$[\d]{2}\$[./A-Za-z0-9]{53}$/)
private _password: string;
@IsOptional()
@IsPhoneNumber(null)
public phoneNumber?: string;
constructor(
email: string,
username: string,
password: string,
phoneNumber?: string
) {
this.email = email;
this.username = username;
this.password = password;
if (phoneNumber) {
this.phoneNumber = phoneNumber;
}
}
} The test I've run: console.log(
validateSync(
new User(
"test.user@test.domain.com",
"I'm way too long to be a username, much too long",
"$2y$12$E6I8o3kUs8CsSs0WnyYiGOmBeVxfhvaEbxPGgJ334jfpB//gEwFYO"
)
)
); This yields no errors: EDIT: My RegEx was wrong. Adding |
Same here I'm trying to use class validator for validating my inputtype in type-graphql but the @matches decorator, is not working, All other decorators with suffix 'Is' are working, but not this one. ``
`` |
For your use case I'd recommend the |
Thanks for suggestion, I solved my issue by stepping down to version 0.10.2 Thank you everyone, I hope this issue gets addressed in later versions. |
@vlapo do you know how can i resolve this |
@rubiin Please provide an example of an input that fails. |
Facing the same issue with class-validator package version 0.11.0
values that pass only each second time:
|
@rubiin Did you resolve your issue? |
I have the same problem
response sometime true, sometime false with same request |
@matches('^09[0-9]{9}',"",{"message":"phone is incorrect"}) after regex pattern we need pass empty string and third argument be our message |
Got the same issue I want to validate time format '/^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$/' but it fails on 08:30 |
As @aozisik explained correctly this is how the
Closing this as there is no action to take from our side. |
@Matches
decorator with my regex shows true sometimes while false sometimes
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I am using class-validator with nestjs. I have a password field like this:
but sometimes the password passes this while sometimes it doesnt
The text was updated successfully, but these errors were encountered: