{"id":48253,"library":"json-gate","title":"json-gate","description":"A friendly, fast JSON schema validator for JavaScript, supporting JSON Schema Draft 3. Current stable version is 0.8.23. The library is minimal and synchronous or asynchronous. It produces detailed, human-friendly error messages. Unlike many modern validators, it only supports Draft 3 (not Draft 4+ or 2020-12), making it a legacy choice. The API is simple: create a schema and validate objects. It is not actively maintained, as the last release was years ago. It has no dependencies.","status":"maintenance","version":"0.8.23","language":"javascript","source_language":"en","source_url":"https://github.com/oferei/json-gate","tags":["javascript","json","schema","validator","validate","assert"],"install":[{"cmd":"npm install json-gate","lang":"bash","label":"npm"},{"cmd":"yarn add json-gate","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-gate","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CommonJS require works but ESM import is preferred for modern projects. The default export is not available.","wrong":"const createSchema = require('json-gate').createSchema","symbol":"createSchema","correct":"import { createSchema } from 'json-gate'"},{"note":"Schema is a named export, not default. You can also create schema via createSchema() which returns a Schema instance.","wrong":"import Schema from 'json-gate'","symbol":"Schema","correct":"import { Schema } from 'json-gate'"},{"note":"SchemaError is thrown on validation failure. It is a named export. In TypeScript, you may need to declare types.","wrong":"const SchemaError = require('json-gate').SchemaError","symbol":"SchemaError","correct":"import { SchemaError } from 'json-gate'"}],"quickstart":{"code":"import { createSchema } from 'json-gate';\n\nconst schema = createSchema({\n  type: 'object',\n  properties: {\n    name: { type: 'string', required: true },\n    age: { type: 'integer', minimum: 0, default: 0 }\n  },\n  additionalProperties: false\n});\n\nconst input = { name: 'Alice' };\n\ntry {\n  schema.validate(input);\n  console.log('Valid!', input);\n} catch (err) {\n  console.error('Validation failed:', err.message);\n}","lang":"typescript","description":"Create a schema, validate an object synchronously, and handle errors."},"warnings":[{"fix":"Use a modern validator like Ajv or @cfworker/json-schema.","message":"json-gate only supports JSON Schema Draft 3. Draft 4 and later features (e.g., const, if/then/else) are not supported.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Clone the input before validating if mutation is undesirable: schema.validate(JSON.parse(JSON.stringify(input))).","message":"validate() mutates the input object when 'default' properties are specified.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Choose one mode consistently. If using callback, pass a function as second argument to avoid exceptions being thrown.","message":"validate() throws an error synchronously but also accepts a callback for async mode. Mixing them can cause confusion.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Install @types/json-gate if available (none exist) or create a declaration file.","message":"The package has no TypeScript definitions. Using with TypeScript requires manual type declarations.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Deep clone the schema before use if reuse is needed without defaults applied.","message":"The schema object is mutated during validation if it contains 'default' values that are applied.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'-12':52 '0.8.23':21 '2020':51 '3':16,46 '4':49 'activ':71 'ago':79 'api':59 'assert':89 'asynchron':29 'choic':57 'creat':62 'current':17 'depend':83 'detail':32 'draft':15,45,48 'error':36 'fast':6 'friend':5,35 'gate':3 'human':34 'human-friend':33 'javascript':11,84 'json':2,7,13,85 'json-gat':1 'last':75 'legaci':56 'librari':23 'maintain':72 'make':53 'mani':39 'messag':37 'minim':25 'modern':40 'object':67 'produc':31 'releas':76 'schema':8,14,64,86 'simpl':61 'stabl':18 'support':12,44 'synchron':27 'unlik':38 'valid':9,41,66,87,88 'version':19 'year':78","created_at":"2026-06-07T16:55:40.649080+00:00","updated_at":"2026-06-07T16:55:40.649080+00:00","problems":[{"fix":"Use import { createSchema } from 'json-gate' instead of import createSchema from 'json-gate'.","cause":"Default import used when named import is required.","error":"TypeError: json_gate_1.createSchema is not a function"},{"fix":"Ensure input values meet schema requirements.","cause":"Input violates schema constraint (maximum).","error":"SchemaError: JSON object property 'age': value 150 is greater than maximum 120"},{"fix":"Set 'additionalProperties' to a boolean or a schema object.","cause":"Schema definition has invalid type for reserved keyword.","error":"Error: Schema property 'additionalProperties' is not a boolean"},{"fix":"Ensure createSchema() is called with a valid schema object and returns a Schema instance.","cause":"createSchema() was not called correctly, or the schema variable is undefined.","error":"TypeError: schema.validate is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/oferei/json-gate#readme","github":"https://github.com/oferei/json-gate","docs":null,"changelog":null,"pypi":null,"npm":"json-gate","openapi_spec":null,"status_page":null,"smithery":null,"categories":["validation"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}