class-validator-multi-lang
Version:
Decorator-based property validation for classes.
25 lines • 954 B
JavaScript
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isUppercaseValidator from 'validator/lib/isUppercase';
import { getText } from '../../multi-lang';
export var IS_UPPERCASE = 'isUppercase';
/**
* Checks if the string is uppercase.
* If given value is not a string, then it returns false.
*/
export function isUppercase(value) {
return typeof value === 'string' && isUppercaseValidator(value);
}
/**
* Checks if the string is uppercase.
* If given value is not a string, then it returns false.
*/
export function IsUppercase(validationOptions) {
return ValidateBy({
name: IS_UPPERCASE,
validator: {
validate: function (value, args) { return isUppercase(value); },
defaultMessage: buildMessage(function (eachPrefix) { return eachPrefix + getText('$property must be uppercase'); }, validationOptions),
},
}, validationOptions);
}
//# sourceMappingURL=IsUppercase.js.map