Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript: JSON schema to validate another JSON schema

I'm facing right now an application which needs to validate a form with a definition of JSON Schema inside.

I would want to know if there's a validator schema for JSON Schema on JavaScript

For example:

let validate = schemaValidator.validate('{"title": "Example Schema","type": "object","properties": {"firstName": {"type": "string"},"lastName": {"type": "string"},"age": {"description": "Age in years","type": "integer","minimum": 0}},"required": ["firstName", "lastName"]}', metaSchema);

Formatted JSON

{
  "title": "Example Schema",
  "type": "object",
  "properties": {
    "firstName": {
      "type": "string"
    },
    "lastName": {
      "type": "string"
    },
    "age": {
      "description": "Age in years",
      "type": "integer",
      "minimum": 0
    }
  },
  "required": ["firstName", "lastName"]
}

Thanks,

like image 980
SedueRey Avatar asked May 27 '26 03:05

SedueRey


1 Answers

The Schema Draft v4 is itself a JSON Schema you can use for validation of JSON Schemas.

like image 175
Iso Avatar answered May 28 '26 18:05

Iso



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!