-
Notifications
You must be signed in to change notification settings - Fork 16
/
jest-validate.node.txt
54 lines (44 loc) · 3.74 KB
/
jest-validate.node.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
JEST-VALIDATE
ALTERNATIVES ==> #See JSON schema
VERSION ==> #See Jest (monorepo)
validate(OBJ, OPTS)->OBJ3 #Validates OBJ against OPTS.exampleConfig|deprecatedConfig
#Returns OBJ3:
# - isValid BOOL
# - hasDeprecationWarnings BOOL: true if at least one deprecate() returned true
OPTS.recursive #BOOL (def: true)
OPTS.recursiveDenylist #'VARR'_ARR
OPTS.exampleConfig #OBJ2
#If OBJ.VAR !== undefined|null && different type than OBJ2.VAR:
# - "type" is either:
# - typeof
# - Object.prototype.toString(VAL):
# - can distinguish between most native OBJ types
# - including FUNC vs async FUNC
# - but not inheritance / child types
# - then throw ValidateError() with nice error message
#If OBJ.VAR !== undefined && OBJ2.VAR === undefined:
# - then console.warn() with nice error message
# - including possible typos (using Levenshtein distance)
#Values are used as example in messages
#OBJ.VAR can be JEST-VALIDATE.multipleValidOptions(VAL, ...) instead of VAL to
#allow multiple types (not multiple values / enum)
OPTS.deprecatedConfig #{ VAR(OPTS)->'ERROR', ... }:
#If OBJ.VAR !== undefined && OBJ4.VAR !== undefined
# - then console.warn() 'ERROR' with a nice error message
OPTS.title. #STR:
deprecation|error|warning #Prepended to default error messages for deprecate|error|unknown()
#Def: '● Deprecation|Validation Warning|Error'
OPTS.comment #STR (def: ''):
#Appended to every default error message for deprecate(), error()
#E.g. link to online documentation
OPTS.deprecate(OBJ, 'VAR',
OPTS.deprecatedConfig, OPTS)
->BOOL #Customize deprecatedConfig warning behavior
OPTS.error
('VAR', OBJ.VAR, OBJ2.VAR, OPTS) #Customize typing error throwing behavior
OPTS.condition(OBJ.VAR, OBJ2.VAR)
->BOOL #Customize typing check behavior
OPTS.unknown
(OBJ, OBJ2, 'VAR', OPTS) #Customize unknown VAR behavior