UNPKG

975 BJavaScriptView Raw
1import { buildMessage, ValidateBy } from '../common/ValidateBy';
2import isVariableWidthValidator from 'validator/lib/isVariableWidth';
3export const IS_VARIABLE_WIDTH = 'isVariableWidth';
4/**
5 * Checks if the string contains variable-width chars.
6 * If given value is not a string, then it returns false.
7 */
8export function isVariableWidth(value) {
9 return typeof value === 'string' && isVariableWidthValidator(value);
10}
11/**
12 * Checks if the string contains variable-width chars.
13 * If given value is not a string, then it returns false.
14 */
15export function IsVariableWidth(validationOptions) {
16 return ValidateBy({
17 name: IS_VARIABLE_WIDTH,
18 validator: {
19 validate: (value, args) => isVariableWidth(value),
20 defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must contain a full-width and half-width characters', validationOptions),
21 },
22 }, validationOptions);
23}
24//# sourceMappingURL=IsVariableWidth.js.map
\No newline at end of file