@dnax/core 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/schema.ts CHANGED
@@ -14,14 +14,18 @@ function buildSchema(col: Collection) {
14
14
  }
15
15
 
16
16
  if (f?.type == "uuid" && f?.random?.toNumber) {
17
- // propertySchema[f.name] = v.string();
17
+ propertySchema[f.name] = v.string();
18
+ }
19
+
20
+ if (f?.type == "random") {
21
+ propertySchema[f.name] = v.string().optional();
18
22
  }
19
23
 
20
24
  if (f?.type == "random" && f?.random?.toNumber) {
21
- // propertySchema[f.name] = v.number();
25
+ propertySchema[f.name] = v.number().optional();
22
26
  }
23
27
  if (f?.type == "random" && !f?.random?.toNumber) {
24
- // propertySchema[f.name] = v.string();
28
+ propertySchema[f.name] = v.string().optional();
25
29
  }
26
30
 
27
31
  if (f?.type.match(/(string|richText|textarea)/)) {
@@ -85,9 +89,7 @@ function buildSchema(col: Collection) {
85
89
  });
86
90
  }
87
91
 
88
- if (f?.type == "random") {
89
- // propertySchema[f.name] = v.any();
90
- }
92
+
91
93
 
92
94
  if (f?.type == "password") {
93
95
  propertySchema[f.name] = v.string();
@@ -122,7 +124,10 @@ function buildSchema(col: Collection) {
122
124
  if (!f?.validate?.schema) {
123
125
  if (f?.nullable) {
124
126
  propertySchema[f.name] = propertySchema[f.name].optional();
125
- } else {
127
+ }
128
+
129
+ if(f?.required){
130
+ if(!f?.type?.match(/(random)/))
126
131
  propertySchema[f.name] = propertySchema[f.name].required();
127
132
  }
128
133
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {
package/types/index.ts CHANGED
@@ -96,6 +96,7 @@ export type Field = {
96
96
  multiple?: boolean;
97
97
  items: Array<any>;
98
98
  };
99
+ required?: boolean;
99
100
  nullable?: boolean;
100
101
  defaultValue?: any;
101
102
  unique?: boolean;