UNPKG

class-validator-extended

Version:
35 lines (34 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IS_AWS_REGION = void 0; exports.IsAwsRegion = IsAwsRegion; const class_validator_1 = require("class-validator"); const is_aws_region_predicate_1 = require("./is-aws-region.predicate"); /** @hidden */ exports.IS_AWS_REGION = 'isAwsRegion'; /** * Checks if the given value is an AWS region string. * * Beware that this decorator only checks for syntactic validity, it does not check if the region really exists. For * instance, it will accept `eu-central-9` which - at the time of writing - does not exist. * * #### Example * ```typescript * // Ensure the value is a valid looking AWS region * @IsAwsRegion() * region: string = 'eu-central-1' * ``` * * @category String * @deprecated * @param options Generic class-validator options. */ function IsAwsRegion(options) { return (0, class_validator_1.ValidateBy)({ name: exports.IS_AWS_REGION, validator: { validate: (value, _arguments) => (0, is_aws_region_predicate_1.isAwsRegion)(value), defaultMessage: (0, class_validator_1.buildMessage)(eachPrefix => `${eachPrefix}$property must be an AWS region string`, options), }, }, options); }