You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
564 B
JavaScript
15 lines
564 B
JavaScript
4 years ago
|
"use strict";
|
||
|
|
||
|
const ValidationError = require("@validatem/error");
|
||
|
const isString = require("@validatem/is-string");
|
||
|
|
||
|
module.exports = [
|
||
|
isString,
|
||
|
function isUppercase(value) {
|
||
|
// By applying a case transformation and then comparing, instead of eg. using a regular expression, we outsource the decision of "what counts as uppercase" to the JS runtime (which means we don't need to worry about things like non-obvious cases in non-English writing systems)
|
||
|
if (value.toUpperCase() !== value) {
|
||
|
throw new ValidationError(`Must be all-uppercase`);
|
||
|
}
|
||
|
}
|
||
|
];
|