File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ --------------------------------------------------
2
+ <a name =" 1.6.0 " ></a >
3
+ # 1.6.0 (2020-08-06)
4
+
5
+ ## New ` objectID ` rule
6
+ You can validate BSON/MongoDB ObjectID's
7
+
8
+ ** Example**
9
+ ``` js
10
+ const { ObjectID } = require (" mongodb" ) // or anywhere else
11
+ const schema = {
12
+ id: {
13
+ type: " objectID" ,
14
+ ObjectID // passing the ObjectID class
15
+ }
16
+ }
17
+ const check = v .compile (schema);
18
+ check ({ id: " 5f082780b00cc7401fb8e8fc" }) // ok
19
+ check ({ id: new ObjectID () }) // ok
20
+ check ({ id: " 5f082780b00cc7401fb8e8" }) // Error
21
+ ```
22
+
23
+ ## Dynamic default value
24
+ You can use dynamic default value by defining a function that returns a value.
25
+
26
+ ** Example**
27
+ In the following code, if ` createdAt ` field not defined in object`, the validator sets the current time into the property:
28
+ ``` js
29
+ const schema = {
30
+ createdAt: {
31
+ type: " date" ,
32
+ default : () => new Date ()
33
+ }
34
+ };
35
+ const obj = {}
36
+ v .validate (obj, schema); // Valid
37
+ console .log (obj);
38
+ /*
39
+ {
40
+ createdAt: Date(2020-07-25T13:17:41.052Z)
41
+ }
42
+ */
43
+ ```
44
+
45
+ ## Changes
46
+ - Add support for uuid v6. [ #181 ] ( https://github.com/icebob/fastest-validator/issues/181 )
47
+ - Add ` addMessage ` method for using in plugins [ #166 ] ( https://github.com/icebob/fastest-validator/issues/166 )
48
+ - Fix uppercase uuid issue. [ #176 ] ( https://github.com/icebob/fastest-validator/issues/176 )
49
+ - Add ` singleLine ` property to ` string ` rule. [ #180 ] ( https://github.com/icebob/fastest-validator/issues/180 )
50
+
51
+ ## Credits
52
+ Many thanks to @intech and @erfanium for contributing.
53
+
54
+ --------------------------------------------------
1
55
<a name =" 1.5.1 " ></a >
2
56
# 1.5.1 (2020-06-19)
3
57
You can’t perform that action at this time.
0 commit comments