UNPKG

fluent-ts-validator

Version:
109 lines 3.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const _1 = require("./"); const validation_1 = require("../validation"); const string_based_1 = require("../validators/string-based"); const IsLatLongValidator_1 = require("../validators/string-based/IsLatLongValidator"); class StringValidatorBuilderImpl extends _1.CommonValidatorBuilderImpl { constructor(validationRule) { super(validationRule); } buildRuleWith(validator) { this.validationRule.addValidator(validator); return this; } /* * ================== * Validation options * ================== */ whenNotEmpty() { this.validationRule.addCondition(new validation_1.WhenNotEmptyCondition(this.validationRule.lambdaExpression)); return this; } /* * ============================= * String-based validation rules * ============================= */ isBooleanString() { return this.buildRuleWith(new string_based_1.IsBooleanStringValidator()); } isNumericString() { return this.buildRuleWith(new string_based_1.IsNumericStringValidator()); } isAlpha(locale) { return this.buildRuleWith(new string_based_1.IsAlphaValidator(locale)); } isAlphanumeric(locale) { return this.buildRuleWith(new string_based_1.IsAlphanumericValidator(locale)); } contains(seed) { return this.buildRuleWith(new string_based_1.ContainsValidator(seed)); } isAscii() { return this.buildRuleWith(new string_based_1.IsAsciiValidator()); } isBase64() { return this.buildRuleWith(new string_based_1.IsBase64Validator()); } isCurrency(options) { return this.buildRuleWith(new string_based_1.IsCurrencyValidator(options)); } isDecimalString() { return this.buildRuleWith(new string_based_1.IsDecimalStringValidator()); } isEmail(options) { return this.buildRuleWith(new string_based_1.IsEmailValidator(options)); } isFqdn(options) { return this.buildRuleWith(new string_based_1.IsFqdnValidator(options)); } isHexadecimal() { return this.buildRuleWith(new string_based_1.IsHexadecimalValidator()); } isIso8601() { return this.buildRuleWith(new string_based_1.IsIso8601Validator()); } isJson() { return this.buildRuleWith(new string_based_1.IsJsonValidator()); } isPostalCode(locale) { return this.buildRuleWith(new string_based_1.IsPostalCodeValidator(locale)); } hasLength(length) { return this.buildRuleWith(new string_based_1.HasLengthValidator({ min: length, max: length })); } hasLengthBetween(min, max) { return this.buildRuleWith(new string_based_1.HasLengthValidator({ min: min, max: max })); } hasMinLength(min) { return this.buildRuleWith(new string_based_1.HasLengthValidator({ min: min })); } hasMaxLength(max) { return this.buildRuleWith(new string_based_1.HasLengthValidator({ max: max })); } isLatLong() { return this.buildRuleWith(new IsLatLongValidator_1.IsLatLongValidator()); } isLowercase() { return this.buildRuleWith(new string_based_1.IsLowercaseValidator()); } isMobilePhoneNo(locale) { return this.buildRuleWith(new string_based_1.IsMobilePhoneValidator(locale)); } isUppercase() { return this.buildRuleWith(new string_based_1.IsUppercaseValidator()); } isUrl(options) { return this.buildRuleWith(new string_based_1.IsUrlValidator(options)); } isUuid(version) { return this.buildRuleWith(new string_based_1.IsUuidValidator(version)); } matches(pattern, modifiers) { return this.buildRuleWith(new string_based_1.RegExValidator(pattern, modifiers)); } } exports.StringValidatorBuilderImpl = StringValidatorBuilderImpl; //# sourceMappingURL=StringValidatorBuilderImpl.js.map