on-internet
← Community

class-validator in nestjs has unexpected behavior for phone numbers in body or route

Stack Overflow ·

I am using class-validator and nestjs to preform validation on my Http requests. I am running into an interesting edge case that I am not sure if it is a bug or my implementation is faulty. I have two endpoints: 1) to create data with a valid phone number and 2) to retrieve data by a phone number in the route param. It seems like the route param has more strict validation. I am using the 'US' intl code because my app doesn't support international numbers yet. Here is my implementation: Creating Data with Phone Number /* contact.dto.ts */ export class ContactDto { @IsPhoneNumber('US') public ph

Comments

Sign in or sign up to comment and upvote.

No comments yet.