@dazejs/framework
Version:
Daze.js - A powerful web framework for Node.js
323 lines • 18.8 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.IsISSN = exports.IsISBN = exports.IsIP = exports.IsHexadecimal = exports.IsHexColor = exports.IsHalfWidth = exports.IsFullWidth = exports.IsFQDN = exports.IsEmail = exports.IsCurrency = exports.IsCreditCard = exports.IsByteLength = exports.IsBase64 = exports.IsAscii = exports.IsAlphanumeric = exports.IsAlpha = exports.NotContains = exports.Contains = exports.IsNumberString = exports.IsBooleanString = exports.IsDateString = exports.IsUndefined = exports.IsNull = exports.IsNullOrUndefined = exports.IsSymbol = exports.IsRegExp = exports.IsObject = exports.IsBuffer = exports.IsFunction = exports.IsError = exports.IsArray = exports.IsNumber = exports.IsString = exports.IsDate = exports.IsBoolean = exports.BeforeDate = exports.AfterDate = exports.Max = exports.Min = exports.IsNegative = exports.IsPositive = exports.IsDivisibleBy = exports.IsNotEmpty = exports.IsEmpty = exports.NotEquals = exports.Equals = exports.Required = exports.Is = exports.Accepted = exports.Passed = void 0;
exports.Matches = exports.MaxLength = exports.MinLength = exports.Length = exports.IsUppercase = exports.IsUUID = exports.IsURL = exports.IsSurrogatePair = exports.IsMultibyte = exports.IsMongoId = exports.IsMobilePhone = exports.IsLowercase = exports.IsJSON = exports.IsISO8601 = exports.IsISIN = void 0;
const validators = __importStar(require("../../validate/validators"));
const factory_1 = require("./factory");
const Passed = function (options) {
return (0, factory_1.validatorFactory)(validators.passed, [], Object.assign({ message: '$field must be passed!' }, options));
};
exports.Passed = Passed;
const Accepted = function (options) {
return (0, factory_1.validatorFactory)(validators.accepted, [], Object.assign({ message: '$field must be yes,on or 1' }, options));
};
exports.Accepted = Accepted;
const Is = function (comparison, options) {
return (0, factory_1.validatorFactory)(validators.is, [comparison], Object.assign({ message: '$field must is $1' }, options));
};
exports.Is = Is;
const Required = function (options) {
return (0, factory_1.validatorFactory)(validators.required, [], Object.assign({ message: '$feild must not be undefined' }, options));
};
exports.Required = Required;
const Equals = function (comparison, options) {
return (0, factory_1.validatorFactory)(validators.equals, [comparison], Object.assign({ message: '$field must be equal to $1' }, options));
};
exports.Equals = Equals;
const NotEquals = function (comparison, options) {
return (0, factory_1.validatorFactory)(validators.notEquals, [comparison], Object.assign({ message: '$field shoud not equal to $1' }, options));
};
exports.NotEquals = NotEquals;
const IsEmpty = function (options) {
return (0, factory_1.validatorFactory)(validators.isEmpty, [], Object.assign({ message: '$field must be empty' }, options));
};
exports.IsEmpty = IsEmpty;
const IsNotEmpty = function (options) {
return (0, factory_1.validatorFactory)(validators.isNotEmpty, [], Object.assign({ message: '$field should not be empty' }, options));
};
exports.IsNotEmpty = IsNotEmpty;
const IsDivisibleBy = function (num, options) {
return (0, factory_1.validatorFactory)(validators.isDivisibleBy, [num], Object.assign({ message: '$field must be divisible by $1' }, options));
};
exports.IsDivisibleBy = IsDivisibleBy;
const IsPositive = function (options) {
return (0, factory_1.validatorFactory)(validators.isPositive, [], Object.assign({ message: '$field must be a positive number' }, options));
};
exports.IsPositive = IsPositive;
const IsNegative = function (options) {
return (0, factory_1.validatorFactory)(validators.isNegative, [], Object.assign({ message: '$field must be a negative number' }, options));
};
exports.IsNegative = IsNegative;
const Min = function (min, options) {
return (0, factory_1.validatorFactory)(validators.min, [min], Object.assign({ message: '$field must not be less than $1' }, options));
};
exports.Min = Min;
const Max = function (max, options) {
return (0, factory_1.validatorFactory)(validators.max, [max], Object.assign({ message: '$field must not be greater than $1' }, options));
};
exports.Max = Max;
const AfterDate = function (date, options) {
return (0, factory_1.validatorFactory)(validators.afterDate, [date], Object.assign({ message: '$field date must not be before than $1' }, options));
};
exports.AfterDate = AfterDate;
const BeforeDate = function (date, options) {
return (0, factory_1.validatorFactory)(validators.beforeDate, [date], Object.assign({ message: '$field date must not be after than $1' }, options));
};
exports.BeforeDate = BeforeDate;
const IsBoolean = function (options) {
return (0, factory_1.validatorFactory)(validators.isBoolean, [], Object.assign({ message: '$field must be a boolean value' }, options));
};
exports.IsBoolean = IsBoolean;
const IsDate = function (options) {
return (0, factory_1.validatorFactory)(validators.isDate, [], Object.assign({ message: '$field must be a date value' }, options));
};
exports.IsDate = IsDate;
const IsString = function (options) {
return (0, factory_1.validatorFactory)(validators.isString, [], Object.assign({ message: '$field must be a string value' }, options));
};
exports.IsString = IsString;
const IsNumber = function (options) {
return (0, factory_1.validatorFactory)(validators.isNumber, [], Object.assign({ message: '$field must be a number value' }, options));
};
exports.IsNumber = IsNumber;
const IsArray = function (options) {
return (0, factory_1.validatorFactory)(validators.isArray, [], Object.assign({ message: '$field must be a array value' }, options));
};
exports.IsArray = IsArray;
const IsError = function (options) {
return (0, factory_1.validatorFactory)(validators.isError, [], Object.assign({ message: '$field must be an error' }, options));
};
exports.IsError = IsError;
const IsFunction = function (options) {
return (0, factory_1.validatorFactory)(validators.isFunction, [], Object.assign({ message: '$field must be a function' }, options));
};
exports.IsFunction = IsFunction;
const IsBuffer = function (options) {
return (0, factory_1.validatorFactory)(validators.isBuffer, [], Object.assign({ message: '$field must be a buffer' }, options));
};
exports.IsBuffer = IsBuffer;
const IsObject = function (options) {
return (0, factory_1.validatorFactory)(validators.isObject, [], Object.assign({ message: '$field must be an object value' }, options));
};
exports.IsObject = IsObject;
const IsRegExp = function (options) {
return (0, factory_1.validatorFactory)(validators.isRegExp, [], Object.assign({ message: '$field must be a regexp' }, options));
};
exports.IsRegExp = IsRegExp;
const IsSymbol = function (options) {
return (0, factory_1.validatorFactory)(validators.isSymbol, [], Object.assign({ message: '$field must be a symbol value' }, options));
};
exports.IsSymbol = IsSymbol;
const IsNullOrUndefined = function (options) {
return (0, factory_1.validatorFactory)(validators.isNullOrUndefined, [], Object.assign({ message: '$field must be null or undefined' }, options));
};
exports.IsNullOrUndefined = IsNullOrUndefined;
const IsNull = function (options) {
return (0, factory_1.validatorFactory)(validators.isNull, [], Object.assign({ message: '$field must be null' }, options));
};
exports.IsNull = IsNull;
const IsUndefined = function (options) {
return (0, factory_1.validatorFactory)(validators.isUndefined, [], Object.assign({ message: '$field must be undefined' }, options));
};
exports.IsUndefined = IsUndefined;
const IsDateString = function (options) {
return (0, factory_1.validatorFactory)(validators.isDateString, [], Object.assign({ message: '$field must be a date string value' }, options));
};
exports.IsDateString = IsDateString;
const IsBooleanString = function (options) {
return (0, factory_1.validatorFactory)(validators.isBooleanString, [], Object.assign({ message: '$field must be a boolean string value' }, options));
};
exports.IsBooleanString = IsBooleanString;
const IsNumberString = function (options) {
const _options = options ? [options] : [];
return (0, factory_1.validatorFactory)(validators.isNumberString, _options, Object.assign({ message: '$field must be a number string value' }, options));
};
exports.IsNumberString = IsNumberString;
const Contains = function (seed, options) {
return (0, factory_1.validatorFactory)(validators.contains, [seed], Object.assign({ message: '$field must contain a $1 string' }, options));
};
exports.Contains = Contains;
const NotContains = function (seed, options) {
return (0, factory_1.validatorFactory)(validators.notContains, [seed], Object.assign({ message: '$field should not contain a $1 string' }, options));
};
exports.NotContains = NotContains;
const IsAlpha = function (locale, options) {
const defaultMessage = '$field must contain only letters (a-zA-Z)';
if (locale && typeof locale === 'object') {
return (0, factory_1.validatorFactory)(validators.isAlpha, [locale.locale], Object.assign({ message: defaultMessage }, locale));
}
return (0, factory_1.validatorFactory)(validators.isAlpha, [locale], Object.assign({ message: defaultMessage }, options));
};
exports.IsAlpha = IsAlpha;
const IsAlphanumeric = function (locale, options) {
const defaultMessage = '$field must contain only letters and numbers';
if (locale && typeof locale === 'object') {
return (0, factory_1.validatorFactory)(validators.isAlphanumeric, [locale.locale], Object.assign({ message: defaultMessage }, locale));
}
return (0, factory_1.validatorFactory)(validators.isAlphanumeric, [locale], Object.assign({ message: defaultMessage }, options));
};
exports.IsAlphanumeric = IsAlphanumeric;
const IsAscii = function (options) {
return (0, factory_1.validatorFactory)(validators.isAscii, [], Object.assign({ message: '$field must contain only ASCII characters' }, options));
};
exports.IsAscii = IsAscii;
const IsBase64 = function (options) {
return (0, factory_1.validatorFactory)(validators.isBase64, [], Object.assign({ message: '$field must be base64 encoded' }, options));
};
exports.IsBase64 = IsBase64;
const IsByteLength = function (min, max, options) {
return (0, factory_1.validatorFactory)(validators.isByteLength, [min, max], Object.assign({ message: '$field\'s byte length must fall into($1, $2) range' }, options));
};
exports.IsByteLength = IsByteLength;
const IsCreditCard = function (options) {
return (0, factory_1.validatorFactory)(validators.isCreditCard, [], Object.assign({ message: '$field must be a credit card' }, options));
};
exports.IsCreditCard = IsCreditCard;
const IsCurrency = function (options) {
const _options = options ? [options] : [];
return (0, factory_1.validatorFactory)(validators.isCurrency, _options, Object.assign({ message: '$field must be a currency' }, options));
};
exports.IsCurrency = IsCurrency;
const IsEmail = function (options) {
const _options = options ? [options] : [];
return (0, factory_1.validatorFactory)(validators.isEmail, _options, Object.assign({ message: '$field must be an email' }, options));
};
exports.IsEmail = IsEmail;
const IsFQDN = function (options) {
const _options = options ? [options] : [];
return (0, factory_1.validatorFactory)(validators.isFQDN, _options, Object.assign({ message: '$field must be a valid domain name' }, options));
};
exports.IsFQDN = IsFQDN;
const IsFullWidth = function (options) {
return (0, factory_1.validatorFactory)(validators.isFullWidth, [], Object.assign({ message: '$field must contain a full-width characters' }, options));
};
exports.IsFullWidth = IsFullWidth;
const IsHalfWidth = function (options) {
return (0, factory_1.validatorFactory)(validators.isHalfWidth, [], Object.assign({ message: '$field must contain a half-width characters' }, options));
};
exports.IsHalfWidth = IsHalfWidth;
const IsHexColor = function (options) {
return (0, factory_1.validatorFactory)(validators.isHexColor, [], Object.assign({ message: '$field must be a hex color' }, options));
};
exports.IsHexColor = IsHexColor;
const IsHexadecimal = function (options) {
return (0, factory_1.validatorFactory)(validators.isHexadecimal, [], Object.assign({ message: '$field must be a hexadecimal number' }, options));
};
exports.IsHexadecimal = IsHexadecimal;
const IsIP = function (version, options) {
const defaultMessage = '$field must be an ip address';
if (version && typeof version === 'object') {
return (0, factory_1.validatorFactory)(validators.isIP, [version.version], Object.assign({ message: defaultMessage }, version));
}
return (0, factory_1.validatorFactory)(validators.isIP, [version], Object.assign({ message: defaultMessage }, options));
};
exports.IsIP = IsIP;
const IsISBN = function (version, options) {
const defaultMessage = '$field must be an ISBN';
if (version && typeof version === 'object') {
return (0, factory_1.validatorFactory)(validators.isISBN, [version.version], Object.assign({ message: defaultMessage }, version));
}
return (0, factory_1.validatorFactory)(validators.isISBN, [version], Object.assign({ message: defaultMessage }, options));
};
exports.IsISBN = IsISBN;
const IsISSN = function (options) {
const _options = options ? [options] : [];
return (0, factory_1.validatorFactory)(validators.isISSN, _options, Object.assign({ message: '$field must be an ISSN' }, options));
};
exports.IsISSN = IsISSN;
const IsISIN = function (options) {
return (0, factory_1.validatorFactory)(validators.isISIN, [], Object.assign({ message: '$field must be an ISIN (stock/security identifier)' }, options));
};
exports.IsISIN = IsISIN;
const IsISO8601 = function (options) {
return (0, factory_1.validatorFactory)(validators.isISO8601, [], Object.assign({ message: '$field must be a valid ISO 8601 date string' }, options));
};
exports.IsISO8601 = IsISO8601;
const IsJSON = function (options) {
return (0, factory_1.validatorFactory)(validators.isJSON, [], Object.assign({ message: '$field must be a json string' }, options));
};
exports.IsJSON = IsJSON;
const IsLowercase = function (options) {
return (0, factory_1.validatorFactory)(validators.isLowercase, [], Object.assign({ message: '$field must be a lowercase string' }, options));
};
exports.IsLowercase = IsLowercase;
const IsMobilePhone = function (locale, options) {
if (locale && typeof locale === 'object') {
return (0, factory_1.validatorFactory)(validators.isMobilePhone, [locale.locale, locale], locale);
}
return (0, factory_1.validatorFactory)(validators.isMobilePhone, [locale, options], Object.assign({ message: '$field must be a mobile phone number' }, options));
};
exports.IsMobilePhone = IsMobilePhone;
const IsMongoId = function (options) {
return (0, factory_1.validatorFactory)(validators.isMongoId, [], Object.assign({ message: '$field must be a mongodb id' }, options));
};
exports.IsMongoId = IsMongoId;
const IsMultibyte = function (options) {
return (0, factory_1.validatorFactory)(validators.isMultibyte, [], Object.assign({ message: '$field must contain one or more multibyte chars' }, options));
};
exports.IsMultibyte = IsMultibyte;
const IsSurrogatePair = function (options) {
return (0, factory_1.validatorFactory)(validators.isSurrogatePair, [], Object.assign({ message: '$field must contain any surrogate pairs chars' }, options));
};
exports.IsSurrogatePair = IsSurrogatePair;
const IsURL = function (options) {
const _options = options ? [options] : [];
return (0, factory_1.validatorFactory)(validators.isURL, _options, Object.assign({ message: '$field must be an URL address' }, options));
};
exports.IsURL = IsURL;
const IsUUID = function (version, options) {
const defaultMessage = '$field must be an UUID';
if (version && typeof version === 'object') {
return (0, factory_1.validatorFactory)(validators.isUUID, [version.version], Object.assign({ message: defaultMessage }, version));
}
return (0, factory_1.validatorFactory)(validators.isUUID, [version], Object.assign({ message: defaultMessage }, options));
};
exports.IsUUID = IsUUID;
const IsUppercase = function (options) {
return (0, factory_1.validatorFactory)(validators.isUppercase, [], Object.assign({ message: '$field must be an uppercase string' }, options));
};
exports.IsUppercase = IsUppercase;
const Length = function (min, max, options) {
return (0, factory_1.validatorFactory)(validators.length, [min, max], Object.assign({ message: '$field must be between $1 and $2' }, options));
};
exports.Length = Length;
const MinLength = function (min, options) {
return (0, factory_1.validatorFactory)(validators.minLength, [min], Object.assign({ message: '$field must not be shorter than $1' }, options));
};
exports.MinLength = MinLength;
const MaxLength = function (max, options) {
return (0, factory_1.validatorFactory)(validators.maxLength, [max], Object.assign({ message: '$field must not be longer than $1' }, options));
};
exports.MaxLength = MaxLength;
const Matches = function (pattern, modifiers, options) {
const defaultMessage = '$field must match $1 regular expression';
if (modifiers && typeof modifiers === 'object') {
return (0, factory_1.validatorFactory)(validators.matches, [pattern, modifiers.modifiers, modifiers], Object.assign({ message: defaultMessage }, modifiers));
}
return (0, factory_1.validatorFactory)(validators.matches, [pattern, modifiers, options], Object.assign({ message: defaultMessage }, options));
};
exports.Matches = Matches;
//# sourceMappingURL=index.js.map