@bxjs/base
Version:
107 lines (106 loc) • 5.1 kB
TypeScript
import * as __V__ from 'class-validator'
import { ValidatorOptions, ValidationOptions, } from 'class-validator'
import * as __T__ from 'class-transformer'
type ZipCodeLocale = 'AD' | 'AT' | 'AU' | 'BE' | 'BG' | 'BR' | 'CA'
| 'CH' | 'CN' | 'CZ' | 'DE' | 'DK' | 'DZ' | 'EE' | 'ES' | 'FI' | 'FR'
| 'GB' | 'GR' | 'HR' | 'HU' | 'ID' | 'IE' | 'IL' | 'IN' | 'IS' | 'IT'
| 'JP' | 'KE' | 'LI' | 'LT' | 'LU' | 'LV' | 'MX' | 'MT' | 'NL' | 'NO'
| 'NZ' | 'PL' | 'PR' | 'PT' | 'RO' | 'RU' | 'SA' | 'SE' | 'SI' | 'SK'
| 'TN' | 'TW' | 'UA' | 'US' | 'ZA' | 'ZM';
declare global {
// 验证器规则的各种统一描述
const V: {
Type: typeof __T__.Type
ValidateNested: typeof __V__.ValidateNested
Allow: typeof __V__.Allow
ValidateIf: typeof __V__.ValidateIf
IsDefined: typeof __V__.IsDefined
Equals: typeof __V__.Equals
NotEquals: typeof __V__.NotEquals
IsEmpty: typeof __V__.IsEmpty
IsNotEmpty: typeof __V__.IsNotEmpty
IsIn: typeof __V__.IsIn
IsNotIn: typeof __V__.IsNotIn
IsOptional: typeof __V__.IsOptional
IsBoolean: typeof __V__.IsBoolean
IsLatLong: typeof __V__.IsLatLong
IsLatitude: typeof __V__.IsLatitude
IsLongitude: typeof __V__.IsLongitude
IsDate: typeof __V__.IsDate
IsNumber: typeof __V__.IsNumber
IsInt: typeof __V__.IsInt
IsString: typeof __V__.IsString
IsDateString: typeof __V__.IsDateString
IsArray: typeof __V__.IsArray
IsEnum: typeof __V__.IsEnum
IsDivisibleBy: typeof __V__.IsDivisibleBy
IsPositive: typeof __V__.IsPositive
IsNegative: typeof __V__.IsNegative
Min: typeof __V__.Min
Max: typeof __V__.Max
MinDate: typeof __V__.MinDate
MaxDate: typeof __V__.MaxDate
IsBooleanString: typeof __V__.IsBooleanString
IsNumberString: typeof __V__.IsNumberString
Contains: typeof __V__.Contains
NotContains: typeof __V__.NotContains
IsAlpha: typeof __V__.IsAlpha
IsAlphanumeric: typeof __V__.IsAlphanumeric
IsDecimal: typeof __V__.IsDecimal // 方法被改写支持number类型和string类型自动兼容适配
IsAscii: typeof __V__.IsAscii
IsBase64: typeof __V__.IsBase64
IsByteLength: typeof __V__.IsByteLength
IsCreditCard: typeof __V__.IsCreditCard
IsCurrency: typeof __V__.IsCurrency
IsEmail: typeof __V__.IsEmail
IsFQDN: typeof __V__.IsFQDN
// IsFullWidth: typeof __V__.IsFullWidth
// IsHalfWidth: typeof __V__.IsHalfWidth
// IsVariableWidth: typeof __V__.IsVariableWidth
IsHexColor: typeof __V__.IsHexColor
IsHexadecimal: typeof __V__.IsHexadecimal
IsMACAddress: typeof __V__.IsMACAddress
IsIP: typeof __V__.IsIP
IsPort: typeof __V__.IsPort
IsISBN: typeof __V__.IsISBN
// BUGFIX: 修复validator符号表与最新实现版本不一致问题,支持CN中国地区邮政编码扩展定义常量。
// 邮编验证器,开发规范统一用zip_code进行英文表达。
IsZipCode: (locale?: ZipCodeLocale, validationOptions?: ValidationOptions) => PropertyDecorator;
// IsISIN: typeof __V__.IsISIN
// IsISO8601: typeof __V__.IsISO8601
IsJSON: typeof __V__.IsJSON
IsJWT: typeof __V__.IsJWT
IsObject: typeof __V__.IsObject
IsNotEmptyObject: typeof __V__.IsNotEmptyObject
IsMobilePhone: typeof __V__.IsMobilePhone
IsPhoneNumber: typeof __V__.IsPhoneNumber
// IsISO31661Alpha2: typeof __V__.IsISO31661Alpha2
// IsISO31661Alpha3: typeof __V__.IsISO31661Alpha3
IsMongoId: typeof __V__.IsMongoId
// IsMultibyte: typeof __V__.IsMultibyte
// IsSurrogatePair: typeof __V__.IsSurrogatePair
IsUrl: typeof __V__.IsUrl
IsUUID: typeof __V__.IsUUID
IsLowercase: typeof __V__.IsLowercase
IsUppercase: typeof __V__.IsUppercase
Length: typeof __V__.Length
MinLength: typeof __V__.MinLength
MaxLength: typeof __V__.MaxLength
Matches: (pattern: RegExp, validationOptions?: ValidationOptions) => Function // 统一为一种规范格式无选择性便于统一(个性进行特殊封装处理)
// IsMilitaryTime: typeof __V__.IsMilitaryTime
// IsHash: typeof __V__.IsHash
// IsISSN: typeof __V__.IsISSN
ArrayContains: typeof __V__.ArrayContains
ArrayNotContains: typeof __V__.ArrayNotContains
ArrayNotEmpty: typeof __V__.ArrayNotEmpty
ArrayMinSize: typeof __V__.ArrayMinSize
ArrayMaxSize: typeof __V__.ArrayMaxSize
ArrayUnique: typeof __V__.ArrayUnique
IsInstance: typeof __V__.IsInstance
}
// class-validator的校验实现方法
// https://github.com/typestack/class-validator
// https://github.com/validatorjs/validator.js
// https://github.com/typestack/class-transformer
function xcheck<T>(TYPE: new () => T, object: T, option?: ValidatorOptions): Promise<T>
}