1
- CodeEngine validation helpers
1
+ Validate
2
2
======================================
3
+ ### Simple validation helpers with user-friendly error messages
3
4
4
- [ ![ Cross-Platform Compatibility] ( https://engine.codes /img/badges/os-badges.svg )] ( https://github.com/CodeEngineOrg/code-engine- validate/blob/master/.github/workflows/CI-CD.yaml )
5
- [ ![ Build Status] ( https://github.com/CodeEngineOrg/code-engine- validate/workflows/CI-CD/badge.svg )] ( https://github.com/CodeEngineOrg/code-engine- validate/blob/master/.github/workflows/CI-CD.yaml )
5
+ [ ![ Cross-Platform Compatibility] ( https://jstools.dev /img/badges/os-badges.svg )] ( https://github.com/JS-DevTools/ validate/blob/master/.github/workflows/CI-CD.yaml )
6
+ [ ![ Build Status] ( https://github.com/JS-DevTools/ validate/workflows/CI-CD/badge.svg )] ( https://github.com/JS-DevTools/ validate/blob/master/.github/workflows/CI-CD.yaml )
6
7
7
- [ ![ Coverage Status] ( https://coveralls.io/repos/github/CodeEngineOrg/code-engine- validate/badge.svg?branch=master )] ( https://coveralls.io/github/CodeEngineOrg/code-engine- validate )
8
- [ ![ Dependencies] ( https://david-dm.org/CodeEngineOrg/code-engine- validate.svg )] ( https://david-dm.org/CodeEngineOrg/code-engine- validate )
8
+ [ ![ Coverage Status] ( https://coveralls.io/repos/github/JS-DevTools/ validate/badge.svg?branch=master )] ( https://coveralls.io/github/JS-DevTools/ validate )
9
+ [ ![ Dependencies] ( https://david-dm.org/JS-DevTools/ validate.svg )] ( https://david-dm.org/JS-DevTools/ validate )
9
10
10
- [ ![ npm] ( https://img.shields.io/npm/v/@code-engine /validate.svg )] ( https://www.npmjs.com/package/@code-engine /validate )
11
- [ ![ License] ( https://img.shields.io/npm/l/@code-engine /validate.svg )] ( LICENSE )
12
- [ ![ Buy us a tree] ( https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen )] ( https://plant.treeware.earth/CodeEngineOrg/code-engine- validate )
11
+ [ ![ npm] ( https://img.shields.io/npm/v/@jsdevtools /validate.svg )] ( https://www.npmjs.com/package/@jsdevtools /validate )
12
+ [ ![ License] ( https://img.shields.io/npm/l/@jsdevtools /validate.svg )] ( LICENSE )
13
+ [ ![ Buy us a tree] ( https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen )] ( https://plant.treeware.earth/JS-DevTools/ validate )
13
14
14
15
15
16
16
- This is a utility library that's used inside [ CodeEngine] ( https://engine.codes/ ) to validate inputs.
17
+ Installation
18
+ --------------------------
19
+ You can install this library via [ npm] ( https://docs.npmjs.com/about-npm/ ) .
17
20
18
- > ** NOTE:** This is an ** internal library** that is only intended to be used by CodeEngine. Using it outside of CodeEngine is discouraged.
21
+ ``` bash
22
+ npm install @jsdevtools/validate
23
+ ```
19
24
20
25
21
26
@@ -32,7 +37,7 @@ Validates any value that is not `undefined`. (even `null` and `NaN`)
32
37
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
33
38
34
39
``` javascript
35
- import validate from " @code-engine /validate" ;
40
+ import validate from " @jsdevtools /validate" ;
36
41
37
42
validate .value (0 ); // ✔
38
43
validate .value (false ); // ✔
@@ -52,7 +57,7 @@ Validates a value that is one of the specified values.
52
57
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
53
58
54
59
``` javascript
55
- import validate from " @code-engine /validate" ;
60
+ import validate from " @jsdevtools /validate" ;
56
61
57
62
validate .value .oneOf (" a" , [" a" , " b" , " c" ]); // ✔
58
63
validate .value .oneOf (4 , [1 , 2 , 3 , 4 , 5 ]); // ✔
@@ -71,7 +76,7 @@ Validates a value that is the specified type.
71
76
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
72
77
73
78
``` javascript
74
- import validate from " @code-engine /validate" ;
79
+ import validate from " @jsdevtools /validate" ;
75
80
76
81
validate .type (" John" , String ); // ✔
77
82
validate .type (42 , Number ); // ✔
@@ -98,7 +103,7 @@ Validates a value that is the specified type.
98
103
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
99
104
100
105
``` javascript
101
- import validate from " @code-engine /validate" ;
106
+ import validate from " @jsdevtools /validate" ;
102
107
103
108
validate .type .oneOf (" John" , [Number , String , Boolean ]); // ✔
104
109
validate .type .oneOf (42 , [Number , BigInt, Date ]); // ✔
@@ -119,7 +124,7 @@ Validates a primitive string value (including empty strings).
119
124
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
120
125
121
126
``` javascript
122
- import validate from " @code-engine /validate" ;
127
+ import validate from " @jsdevtools /validate" ;
123
128
124
129
validate .type .string (" John" ); // ✔
125
130
validate .type .string (" " ); // ✔
@@ -141,7 +146,7 @@ Validates a primitive number value (**not** including `NaN`).
141
146
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
142
147
143
148
``` javascript
144
- import validate from " @code-engine /validate" ;
149
+ import validate from " @jsdevtools /validate" ;
145
150
146
151
validate .type .number (0 ) // ✔
147
152
validate .type .number (123 ) // ✔
@@ -163,7 +168,7 @@ Validates a primitive boolean value.
163
168
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
164
169
165
170
``` javascript
166
- import validate from " @code-engine /validate" ;
171
+ import validate from " @jsdevtools /validate" ;
167
172
168
173
validate .type .boolean (false ) // ✔
169
174
validate .type .boolean (true ) // ✔
@@ -183,7 +188,7 @@ Validates an object (**not** including `null`).
183
188
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
184
189
185
190
``` javascript
186
- import validate from " @code-engine /validate" ;
191
+ import validate from " @jsdevtools /validate" ;
187
192
188
193
validate .type .object ({}) // ✔
189
194
validate .type .object (/ ^ regex$ / ) // ✔
@@ -205,7 +210,7 @@ Validates any type of function, including async, generators, arrow functions, cl
205
210
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
206
211
207
212
``` javascript
208
- import validate from " @code-engine /validate" ;
213
+ import validate from " @jsdevtools /validate" ;
209
214
210
215
validate .type .function (Object ) // ✔
211
216
validate .type .function (Object .toString ) // ✔
@@ -231,7 +236,7 @@ Validates a string with at least one character (including whitespace).
231
236
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
232
237
233
238
``` javascript
234
- import validate from " @code-engine /validate" ;
239
+ import validate from " @jsdevtools /validate" ;
235
240
236
241
validate .string .nonEmpty (" John" ) // ✔
237
242
validate .string .nonEmpty (" " ) // ✔
@@ -252,7 +257,7 @@ Validates a string with at least one non-whitespace character.
252
257
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
253
258
254
259
``` javascript
255
- import validate from " @code-engine /validate" ;
260
+ import validate from " @jsdevtools /validate" ;
256
261
257
262
validate .string .nonWhitespace (" John" ) // ✔
258
263
validate .string .nonWhitespace (" a " ) // ✔
@@ -274,7 +279,7 @@ Validates a string with at least the specified number of characters (including w
274
279
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
275
280
276
281
``` javascript
277
- import validate from " @code-engine /validate" ;
282
+ import validate from " @jsdevtools /validate" ;
278
283
279
284
validate .string .minLength (" John" , 1 ) // ✔
280
285
validate .string .minLength (" a " , 5 ) // ✔
@@ -294,7 +299,7 @@ Validates a string with no more than the specified number of characters (includi
294
299
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
295
300
296
301
``` javascript
297
- import validate from " @code-engine /validate" ;
302
+ import validate from " @jsdevtools /validate" ;
298
303
299
304
validate .string .maxLength (" John" , 10 ) // ✔
300
305
validate .string .maxLength (" a " , 5 ) // ✔
@@ -314,7 +319,7 @@ Validates a string with the specified number of characters (including whitespace
314
319
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
315
320
316
321
``` javascript
317
- import validate from " @code-engine /validate" ;
322
+ import validate from " @jsdevtools /validate" ;
318
323
319
324
validate .string .length (" John" , 1 , 10 ) // ✔
320
325
validate .string .length (" a " , 5 , 25 ) // ✔
@@ -336,7 +341,7 @@ Validates an integer value (positive or negative).
336
341
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
337
342
338
343
``` javascript
339
- import validate from " @code-engine /validate" ;
344
+ import validate from " @jsdevtools /validate" ;
340
345
341
346
validate .number .integer (0 ); // ✔
342
347
validate .number .integer (42 ); // ✔
@@ -356,7 +361,7 @@ Validates a positive integer value (one or more).
356
361
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
357
362
358
363
``` javascript
359
- import validate from " @code-engine /validate" ;
364
+ import validate from " @jsdevtools /validate" ;
360
365
361
366
validate .number .integer .positive (42 ); // ✔
362
367
validate .number .integer .positive (12345.0 ); // ✔
@@ -374,7 +379,7 @@ Validates an integer value that is zero or greater.
374
379
- ** defaultValue** - (optional) The default value to use if ` value ` is ` undefined ` .
375
380
376
381
``` javascript
377
- import validate from " @code-engine /validate" ;
382
+ import validate from " @jsdevtools /validate" ;
378
383
379
384
validate .number .integer .nonNegative (0 ); // ✔
380
385
validate .number .integer .nonNegative (42 ); // ✔
@@ -387,13 +392,13 @@ validate.number.integer.nonNegative(-42); // ❌
387
392
388
393
Contributing
389
394
--------------------------
390
- Contributions, enhancements, and bug-fixes are welcome! [ File an issue] ( https://github.com/CodeEngineOrg/code-engine- validate/issues ) on GitHub and [ submit a pull request] ( https://github.com/CodeEngineOrg/code-engine- validate/pulls ) .
395
+ Contributions, enhancements, and bug-fixes are welcome! [ File an issue] ( https://github.com/JS-DevTools/ validate/issues ) on GitHub and [ submit a pull request] ( https://github.com/JS-DevTools/ validate/pulls ) .
391
396
392
397
#### Building
393
398
To build the project locally on your computer:
394
399
395
400
1 . __ Clone this repo__ <br >
396
- ` git clone https://github.com/CodeEngineOrg/code-engine- validate.git `
401
+ ` git clone https://github.com/JS-DevTools/ validate.git `
397
402
398
403
2 . __ Install dependencies__ <br >
399
404
` npm install `
@@ -408,16 +413,16 @@ To build the project locally on your computer:
408
413
409
414
License
410
415
--------------------------
411
- @code-engine /validate is 100% free and open-source, under the [ MIT license] ( LICENSE ) . Use it however you want.
416
+ @jsdevtools /validate is 100% free and open-source, under the [ MIT license] ( LICENSE ) . Use it however you want.
412
417
413
- This package is [ Treeware] ( http://treeware.earth ) . If you use it in production, then we ask that you [ ** buy the world a tree** ] ( https://plant.treeware.earth/CodeEngineOrg/code-engine- validate ) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
418
+ This package is [ Treeware] ( http://treeware.earth ) . If you use it in production, then we ask that you [ ** buy the world a tree** ] ( https://plant.treeware.earth/JS-DevTools/ validate ) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
414
419
415
420
416
421
417
422
Big Thanks To
418
423
--------------------------
419
424
Thanks to these awesome companies for their support of Open Source developers ❤
420
425
421
- [ ![ Travis CI] ( https://engine.codes /img/badges/travis-ci.svg )] ( https://travis-ci.com )
422
- [ ![ SauceLabs] ( https://engine.codes /img/badges/sauce-labs.svg )] ( https://saucelabs.com )
423
- [ ![ Coveralls] ( https://engine.codes /img/badges/coveralls.svg )] ( https://coveralls.io )
426
+ [ ![ Travis CI] ( https://jstools.dev /img/badges/travis-ci.svg )] ( https://travis-ci.com )
427
+ [ ![ SauceLabs] ( https://jstools.dev /img/badges/sauce-labs.svg )] ( https://saucelabs.com )
428
+ [ ![ Coveralls] ( https://jstools.dev /img/badges/coveralls.svg )] ( https://coveralls.io )
0 commit comments