UNPKG

1.73 kBSource Map (JSON)View Raw
1{"version":3,"file":"IsFullWidth.js","sourceRoot":"","sources":["../../../../src/decorator/string/IsFullWidth.ts"],"names":[],"mappings":";;;;;;AACA,qDAAgE;AAChE,4EAA6D;AAEhD,QAAA,aAAa,GAAG,aAAa,CAAC;AAE3C;;;GAGG;AACH,SAAgB,WAAW,CAAC,KAAc;IACxC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAA,qBAAoB,EAAC,KAAK,CAAC,CAAC;AAClE,CAAC;AAFD,kCAEC;AAED;;;GAGG;AACH,SAAgB,WAAW,CAAC,iBAAqC;IAC/D,OAAO,IAAA,uBAAU,EACf;QACE,IAAI,EAAE,qBAAa;QACnB,SAAS,EAAE;YACT,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAW,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC;YACtD,cAAc,EAAE,IAAA,yBAAY,EAC1B,UAAU,CAAC,EAAE,CAAC,UAAU,GAAG,gDAAgD,EAC3E,iBAAiB,CAClB;SACF;KACF,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC;AAdD,kCAcC","sourcesContent":["import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy';\nimport isFullWidthValidator from 'validator/lib/isFullWidth';\n\nexport const IS_FULL_WIDTH = 'isFullWidth';\n\n/**\n * Checks if the string contains any full-width chars.\n * If given value is not a string, then it returns false.\n */\nexport function isFullWidth(value: unknown): boolean {\n return typeof value === 'string' && isFullWidthValidator(value);\n}\n\n/**\n * Checks if the string contains any full-width chars.\n * If given value is not a string, then it returns false.\n */\nexport function IsFullWidth(validationOptions?: ValidationOptions): PropertyDecorator {\n return ValidateBy(\n {\n name: IS_FULL_WIDTH,\n validator: {\n validate: (value, args): boolean => isFullWidth(value),\n defaultMessage: buildMessage(\n eachPrefix => eachPrefix + '$property must contain a full-width characters',\n validationOptions\n ),\n },\n },\n validationOptions\n );\n}\n"]}
\No newline at end of file