A library for writing JSON Schema definitions in a more concise, semantic way. Current stable version 0.4.5. It reduces verbosity by allowing schema declarations using familiar JavaScript patterns (e.g., regex for strings, numbers with method chaining). Key differentiators include built-in sugar for common patterns (like arrays of allowed values), a validator class that wraps AJV, and the ability to normalize schemas to standard JSON Schema. Released as an npm package with infrequent updates, it is primarily aimed at developers who find raw JSON Schema too verbose.
npm install semantic-schemaNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates an object schema with required properties using sugar syntax, then validates data.
Run npm install ajv alongside semantic-schema.
Be explicit about chaining, and note that array sugar is shorthand for enum.
Always check the return value and then call .errorsText() to get error messages.
Use regex with ^ and $ explicitly; otherwise don't use regex sugar.
Ensure you create a new Validator from a schema: const validator = new Validator(schema);
Install ajv: npm install ajv
Use schema builders (e.g., integer()) and chain methods; sugar objects like /regex/ cannot be normalized directly.