monmedx-validators
v1.0.4
Published
``` // to get the number in E.164 format, all you have to do is, pass the phone to phoneTransformer
Downloads
24
Readme
Example
// to get the number in E.164 format, all you have to do is, pass the phone to phoneTransformer
import { phoneTransformer, IsValidPhoneNumber } from "./src";
const transformedNumber = phoneTransformer("+12312312312");
console.log(); // here you are going to get number formatted in E.164, but that doesn't ensure that the number is valid number
// to check if the number is valid you have to pass it to phoneValidator util, in case its valid its going to return true, otherwise you going to receive false
console.log(new IsValidPhoneNumber().validate(transformedNumber));
Example with NestJS
@Transform((value) =>
typeof value === 'string' ? phoneTransformer(value, "fieldName") : value,
)
@Validate(IsValidPhoneNumber, {
message: 'number must be valid phone number',
})