"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IsValidPhoneNumber = IsValidPhoneNumber;
const class_validator_1 = require("class-validator");
function IsValidPhoneNumber(validationOptions) {
    return function (object, propertyName) {
        (0, class_validator_1.registerDecorator)({
            name: 'IsValidPhoneNumber',
            target: object.constructor,
            propertyName: propertyName,
            options: validationOptions,
            validator: {
                validate(value, args) {
                    const phoneRegex = /^\+?[1-9]\d{1,14}$/;
                    return typeof value === 'string' && phoneRegex.test(value);
                },
                defaultMessage(args) {
                    return `${args.property} must be a valid phone number`;
                }
            }
        });
    };
}
//# sourceMappingURL=IsValidPhoneNumber.js.map