metaschema
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -5,2 +5,7 @@ # Changelog | ||
## [1.1.2][] - 2021-05-08 | ||
- Shorthand for optional (not required) fields | ||
- Nested schema of json type (for pg json fields) | ||
## [1.1.1][] - 2021-05-07 | ||
@@ -46,3 +51,4 @@ | ||
[unreleased]: https://github.com/metarhia/metaschema/compare/v1.1.1...HEAD | ||
[unreleased]: https://github.com/metarhia/metaschema/compare/v1.1.2...HEAD | ||
[1.1.2]: https://github.com/metarhia/metaschema/compare/v1.1.1...v1.1.2 | ||
[1.1.1]: https://github.com/metarhia/metaschema/compare/v1.1.0...v1.1.1 | ||
@@ -49,0 +55,0 @@ [1.1.0]: https://github.com/metarhia/metaschema/compare/v1.0.3...v1.1.0 |
@@ -168,11 +168,20 @@ 'use strict'; | ||
const short = shorthand(entry); | ||
const type = short || entry.type; | ||
let type = short || entry.type; | ||
if (!type) { | ||
if (this.preprocessIndex(key, entry)) continue; | ||
this.fields[key] = Schema.from(entry); | ||
if (entry.json) { | ||
const json = Schema.from(entry.json); | ||
this.fields[key] = Object.assign({}, entry, { type: 'json', json }); | ||
} else { | ||
this.fields[key] = Schema.from(entry); | ||
} | ||
continue; | ||
} | ||
let required = true; | ||
if (type.startsWith('?')) { | ||
type = type.substring(1); | ||
required = false; | ||
} | ||
const def = short ? toLongForm(type, { ...entry }) : entry; | ||
if (!Reflect.has(def, 'required')) def.required = true; | ||
if (!Reflect.has(def, 'required')) def.required = required; | ||
if (def.length) def.length = formatLength(def.length); | ||
@@ -214,2 +223,7 @@ this.fields[key] = def; | ||
} | ||
if (def.json instanceof Schema) { | ||
const subcheck = def.json.check(value); | ||
if (!subcheck.valid) errors.push(...subcheck.errors); | ||
continue; | ||
} | ||
if (!def) { | ||
@@ -216,0 +230,0 @@ errors.push(`Field "${name}" is not expected`); |
{ | ||
"name": "metaschema", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Metadata Schema and Interface Definition Language (IDL)", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18980
417