Browse Source

Initial commit

Sven Slootweg 3 months ago
commit
b4a2872ace
6 changed files with 235 additions and 0 deletions
  1. 1 0
      .gitignore
  2. 5 0
      README.md
  3. 11 0
      example.js
  4. 14 0
      index.js
  5. 20 0
      package.json
  6. 184 0
      yarn.lock

+ 1 - 0
.gitignore

@ -0,0 +1 @@
1
node_modules

+ 5 - 0
README.md

@ -0,0 +1,5 @@
1
# @validatem/is-uppercase
2
3
Documentation for this module has not been written yet. By the time it reaches 1.0.0, it will have full documentation.
4
5
In the meantime, check out the `example.js` file in the repository for a usage demonstration.

+ 11 - 0
example.js

@ -0,0 +1,11 @@
1
"use strict";
2
3
const { validateValue } = require("@validatem/core");
4
const isUppercase = require("./");
5
6
console.log(validateValue("HELLO WORLD!", [ isUppercase ])); // HELLO WORLD!
7
8
console.log(validateValue("Hello World!", [ isUppercase ])); /*
9
	AggregrateValidationError: One or more validation errors occurred:
10
	 - At (root): Must be all-uppercase
11
*/

+ 14 - 0
index.js

@ -0,0 +1,14 @@
1
"use strict";
2
3
const ValidationError = require("@validatem/error");
4
const isString = require("@validatem/is-string");
5
6
module.exports = [
7
	isString,
8
	function isUppercase(value) {
9
		// 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)
10
		if (value.toUpperCase() !== value) {
11
			throw new ValidationError(`Must be all-uppercase`);
12
		}
13
	}
14
];

+ 20 - 0
package.json

@ -0,0 +1,20 @@
1
{
2
  "name": "@validatem/is-uppercase",
3
  "description": "Validatem validator for ensuring that a value is a completely uppercase string",
4
  "keywords": [
5
    "validatem",
6
    "validator"
7
  ],
8
  "version": "0.1.0",
9
  "main": "index.js",
10
  "repository": "http://git.cryto.net/validatem/is-uppercase.git",
11
  "author": "Sven Slootweg <admin@cryto.net>",
12
  "license": "WTFPL OR CC0-1.0",
13
  "dependencies": {
14
    "@validatem/error": "^1.0.0",
15
    "@validatem/is-string": "^0.1.1"
16
  },
17
  "devDependencies": {
18
    "@validatem/core": "^0.3.2"
19
  }
20
}

+ 184 - 0
yarn.lock

@ -0,0 +1,184 @@
1
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
# yarn lockfile v1
3
4
5
"@validatem/annotate-errors@^0.1.2":
6
  version "0.1.2"
7
  resolved "https://registry.yarnpkg.com/@validatem/annotate-errors/-/annotate-errors-0.1.2.tgz#fa9152bb30f4f42b69496b527e38f0c31ff605a9"
8
  integrity sha512-EuX7pzdYI/YpTmZcgdPG481Oi3elAg8JWh/LYXuE1h6MaZk3A8eP5DD33/l7EoKzrysn6y8nCsqNa1ngei562w==
9
  dependencies:
10
    "@validatem/match-validation-error" "^0.1.0"
11
12
"@validatem/any-property@^0.1.0":
13
  version "0.1.2"
14
  resolved "https://registry.yarnpkg.com/@validatem/any-property/-/any-property-0.1.2.tgz#e6cced130ced057ab185d1a61034b77cb277a5ad"
15
  integrity sha512-WHiUM9oKTVc3w1ZWXb2c09yx6pT65Z9oPJC6/rEJtygtsL+H5B8PlAAH16BllPxLF1ebeLlEhXs3qwau5I0USQ==
16
  dependencies:
17
    "@validatem/annotate-errors" "^0.1.2"
18
    "@validatem/combinator" "^0.1.0"
19
    "@validatem/error" "^1.0.0"
20
    "@validatem/validation-result" "^0.1.1"
21
    "@validatem/virtual-property" "^0.1.0"
22
    default-value "^1.0.0"
23
24
"@validatem/combinator@^0.1.0":
25
  version "0.1.1"
26
  resolved "https://registry.yarnpkg.com/@validatem/combinator/-/combinator-0.1.1.tgz#202f31243f8d57cf87f1b449405b134e2fa40c5a"
27
  integrity sha512-crzAYCmKUcb1DC5sSpdof4gWHX81VRmm+REWflhFuRlKH6JHRV5RcBCxEjlDfRrxW2yF6s9i0rQAOyVVE+GGAg==
28
29
"@validatem/core@^0.3.2":
30
  version "0.3.2"
31
  resolved "https://registry.yarnpkg.com/@validatem/core/-/core-0.3.2.tgz#5e1ce1015f8b4d0c4d908da44fd1a68c1f8903b6"
32
  integrity sha512-jSEg/1FZYRNshg4zM5l3iaAKDZFZVfgxpPpV8rX+2PX4RBUcoDSrQvmkUg/tRh7jHjA3hhvcIxoaMvmLXURCDQ==
33
  dependencies:
34
    "@validatem/annotate-errors" "^0.1.2"
35
    "@validatem/any-property" "^0.1.0"
36
    "@validatem/error" "^1.0.0"
37
    "@validatem/is-plain-object" "^0.1.0"
38
    "@validatem/match-validation-error" "^0.1.0"
39
    "@validatem/match-versioned-special" "^0.1.0"
40
    "@validatem/match-virtual-property" "^0.1.0"
41
    "@validatem/normalize-rules" "^0.1.0"
42
    "@validatem/required" "^0.1.0"
43
    "@validatem/validation-result" "^0.1.1"
44
    assure-array "^1.0.0"
45
    create-error "^0.3.1"
46
    default-value "^1.0.0"
47
    flatten "^1.0.3"
48
    is-arguments "^1.0.4"
49
50
"@validatem/error@^1.0.0":
51
  version "1.0.0"
52
  resolved "https://registry.yarnpkg.com/@validatem/error/-/error-1.0.0.tgz#a975904aa4c3e7618d89088a393567a5e1778340"
53
  integrity sha512-7M3tV4DhCuimuCRdC2L/topBByDjhzspzeQGNU0S4/mdn2aDNtESYE43K/2Kh/utCAhqXh2gyw89WYxy//t3fQ==
54
  dependencies:
55
    create-error "^0.3.1"
56
57
"@validatem/has-shape@^0.1.0":
58
  version "0.1.4"
59
  resolved "https://registry.yarnpkg.com/@validatem/has-shape/-/has-shape-0.1.4.tgz#678ebcd2864628515531d75e1b5491387a97bfd9"
60
  integrity sha512-MVN4BOxRfsa2D95Lwp8Dh9I8paAhTYgBpZbDAFnyEv51qlGTQPeAnunnslFS+K38QLa9E96Dk5Vs8Pn7F5XH9g==
61
  dependencies:
62
    "@validatem/annotate-errors" "^0.1.2"
63
    "@validatem/combinator" "^0.1.0"
64
    "@validatem/error" "^1.0.0"
65
    "@validatem/validation-result" "^0.1.1"
66
    as-expression "^1.0.0"
67
    assure-array "^1.0.0"
68
    default-value "^1.0.0"
69
    flatten "^1.0.3"
70
71
"@validatem/is-plain-object@^0.1.0":
72
  version "0.1.1"
73
  resolved "https://registry.yarnpkg.com/@validatem/is-plain-object/-/is-plain-object-0.1.1.tgz#b7a3ef8ef960882c7c41e84ed709fa0bfb932e93"
74
  integrity sha512-aNGbNIbKRpYI0lRBczlTBbiA+nqN52ADAASdySKg2/QeSCVtYS4uOIeCNIJRAgXe/5sUnLTuL4pgq628uAl7Kw==
75
  dependencies:
76
    "@validatem/error" "^1.0.0"
77
    is-plain-obj "^2.1.0"
78
79
"@validatem/is-string@^0.1.1":
80
  version "0.1.1"
81
  resolved "https://registry.yarnpkg.com/@validatem/is-string/-/is-string-0.1.1.tgz#0710d8cebedd4d6861b4a8c63d7803ed6d2f9d6c"
82
  integrity sha512-iyRVYRPgRt2ZlWyc7pzN1WkO6apzE8at39XQa4WUr8qRPfJn12V4khS9MumWbZs8N2qqajrxMigB2LJUCKOCRg==
83
  dependencies:
84
    "@validatem/error" "^1.0.0"
85
    is-string "^1.0.5"
86
87
"@validatem/match-special@^0.1.0":
88
  version "0.1.0"
89
  resolved "https://registry.yarnpkg.com/@validatem/match-special/-/match-special-0.1.0.tgz#4e0c28f1aee5bf53c1ef30bbf8c755d4946ae0ff"
90
  integrity sha512-TFiq9Wk/1Hoja4PK85WwNYnwBXk3+Lgoj59ZIMxm2an1qmNYp8j+BnSvkKBflba451yIn6V1laU9NJf+/NYZgw==
91
92
"@validatem/match-validation-error@^0.1.0":
93
  version "0.1.0"
94
  resolved "https://registry.yarnpkg.com/@validatem/match-validation-error/-/match-validation-error-0.1.0.tgz#fa87f5f1836e7c1d9bf6b75b2addf0a5b21e4c1e"
95
  integrity sha512-6akGTk7DdulOreyqDiGdikwRSixQz/AlvARSX18dcWaTFc79KxCLouL2hyoFcor9IIUhu5RTY4/i756y4T1yxA==
96
  dependencies:
97
    "@validatem/match-versioned-special" "^0.1.0"
98
99
"@validatem/match-versioned-special@^0.1.0":
100
  version "0.1.0"
101
  resolved "https://registry.yarnpkg.com/@validatem/match-versioned-special/-/match-versioned-special-0.1.0.tgz#2eacc48debecdbbe7e3d02f0c0a665afaea9bedf"
102
  integrity sha512-xoOTY0bdA2ELj+ntcDVJ8YyMEFIJpjZ4HNPL9lGcbnRFwJBhQcHUAhUpZwkMxu02zH9wkNM1FvYGHxPz40745Q==
103
104
"@validatem/match-virtual-property@^0.1.0":
105
  version "0.1.0"
106
  resolved "https://registry.yarnpkg.com/@validatem/match-virtual-property/-/match-virtual-property-0.1.0.tgz#4de2de1075987b5f3b356d3f2bcf6c0be5b5fb83"
107
  integrity sha512-ssd3coFgwbLuqvZftLZTy3eHN0TFST8oTS2XTViQdXJPXVoJmwEKBpFhXgwnb5Ly1CE037R/KWpjhd1TP/56kQ==
108
109
"@validatem/normalize-rules@^0.1.0":
110
  version "0.1.2"
111
  resolved "https://registry.yarnpkg.com/@validatem/normalize-rules/-/normalize-rules-0.1.2.tgz#6529f17a6f36c6e2ae3ef285c59347c2ea208aa1"
112
  integrity sha512-IHc81Sy/W0OiCbmvE3kTB+5OPVJnXWHP2tTXvKO6hVH0qykclMvIPRGgZf1s4dLaeOLKdkkfKyO/pLTVyNCIbA==
113
  dependencies:
114
    "@validatem/has-shape" "^0.1.0"
115
    "@validatem/is-plain-object" "^0.1.0"
116
    "@validatem/match-special" "^0.1.0"
117
    assure-array "^1.0.0"
118
    default-value "^1.0.0"
119
    flatten "^1.0.3"
120
    is-plain-obj "^2.1.0"
121
122
"@validatem/required@^0.1.0":
123
  version "0.1.1"
124
  resolved "https://registry.yarnpkg.com/@validatem/required/-/required-0.1.1.tgz#64f4a87333fc5955511634036b7f8948ed269170"
125
  integrity sha512-vI4NzLfay4RFAzp7xyU34PHb8sAo6w/3frrNh1EY9Xjnw2zxjY5oaxwmbFP1jVevBE6QQEnKogtzUHz/Zuvh6g==
126
127
"@validatem/validation-result@^0.1.1":
128
  version "0.1.2"
129
  resolved "https://registry.yarnpkg.com/@validatem/validation-result/-/validation-result-0.1.2.tgz#4e75cfd87305fc78f8d05ac84921a2c99a0348e0"
130
  integrity sha512-okmP8JarIwIgfpaVcvZGuQ1yOsLKT3Egt49Ynz6h1MAeGsP/bGHXkkXtbiWOVsk5Tzku5vDVFSrFnF+5IEHKxw==
131
  dependencies:
132
    default-value "^1.0.0"
133
134
"@validatem/virtual-property@^0.1.0":
135
  version "0.1.0"
136
  resolved "https://registry.yarnpkg.com/@validatem/virtual-property/-/virtual-property-0.1.0.tgz#880540dfd149f98ecf1095d93912e34443381fe4"
137
  integrity sha512-JUUvWtdqoSkOwlsl20oB3qFHYIL05a/TAfdY4AJcs55QeVTiX5iI1b8IoQW644sIWWooBuLv+XwoxjRsQFczlQ==
138
139
as-expression@^1.0.0:
140
  version "1.0.0"
141
  resolved "https://registry.yarnpkg.com/as-expression/-/as-expression-1.0.0.tgz#7bc620ca4cb2fe0ee90d86729bd6add33b8fd831"
142
  integrity sha512-Iqh4GxNUfxbJdGn6b7/XMzc8m1Dz2ZHouBQ9DDTzyMRO3VPPIAXeoY/sucRxxxXKbUtzwzWZSN6jPR3zfpYHHA==
143
144
assure-array@^1.0.0:
145
  version "1.0.0"
146
  resolved "https://registry.yarnpkg.com/assure-array/-/assure-array-1.0.0.tgz#4f4ad16a87659d6200a4fb7103462033d216ec1f"
147
  integrity sha1-T0rRaodlnWIApPtxA0YgM9IW7B8=
148
149
create-error@^0.3.1:
150
  version "0.3.1"
151
  resolved "https://registry.yarnpkg.com/create-error/-/create-error-0.3.1.tgz#69810245a629e654432bf04377360003a5351a23"
152
  integrity sha1-aYECRaYp5lRDK/BDdzYAA6U1GiM=
153
154
default-value@^1.0.0:
155
  version "1.0.0"
156
  resolved "https://registry.yarnpkg.com/default-value/-/default-value-1.0.0.tgz#8c6f52a5a1193fe78fdc9f86eb71d16c9757c83a"
157
  integrity sha1-jG9SpaEZP+eP3J+G63HRbJdXyDo=
158
  dependencies:
159
    es6-promise-try "0.0.1"
160
161
es6-promise-try@0.0.1:
162
  version "0.0.1"
163
  resolved "https://registry.yarnpkg.com/es6-promise-try/-/es6-promise-try-0.0.1.tgz#10f140dad27459cef949973e5d21a087f7274b20"
164
  integrity sha1-EPFA2tJ0Wc75SZc+XSGgh/cnSyA=
165
166
flatten@^1.0.3:
167
  version "1.0.3"
168
  resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.3.tgz#c1283ac9f27b368abc1e36d1ff7b04501a30356b"
169
  integrity sha512-dVsPA/UwQ8+2uoFe5GHtiBMu48dWLTdsuEd7CKGlZlD78r1TTWBvDuFaFGKCo/ZfEr95Uk56vZoX86OsHkUeIg==
170
171
is-arguments@^1.0.4:
172
  version "1.0.4"
173
  resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.0.4.tgz#3faf966c7cba0ff437fb31f6250082fcf0448cf3"
174
  integrity sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==
175
176
is-plain-obj@^2.1.0:
177
  version "2.1.0"
178
  resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287"
179
  integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==
180
181
is-string@^1.0.5:
182
  version "1.0.5"
183
  resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.5.tgz#40493ed198ef3ff477b8c7f92f644ec82a5cd3a6"
184
  integrity sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==