@lucania/schema 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/build/index.js +4 -4
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -157,6 +157,9 @@
157
157
  }
158
158
  const result = _validate(schema.type, source, path, originalSchema, originalSource);
159
159
  if (result instanceof ValidationError && result.type === "missing") {
160
+ if (!schema.required && source === undefined) {
161
+ return undefined;
162
+ }
160
163
  if ("default" in schema) {
161
164
  if (typeof schema.default === "function") {
162
165
  return _validate(schema.type, schema.default(), path, originalSchema, originalSource);
@@ -165,10 +168,7 @@
165
168
  return _validate(schema.type, schema.default, path, originalSchema, originalSource);
166
169
  }
167
170
  }
168
- else if (schema.required) {
169
- return result;
170
- }
171
- return undefined;
171
+ return result;
172
172
  }
173
173
  return result;
174
174
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucania/schema",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "A schema module for compile-time and runtime type checking.",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",