3

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,

4
  • Not sure but JSON.parse might help. It will throw error for any invalid JSON. Commented Jul 18, 2016 at 12:25
  • Are you asking for a library? Commented Jul 18, 2016 at 12:25
  • "JSON schema for validate JSON schema" - You seem to be asking for a schema to validate another schema - is that what you mean? Or do you mean that you want a way to validate that a given JSON string matches the structure of the JSON shown in the question? Commented Jul 18, 2016 at 12:31
  • yes, I would need a schema to validate another schema, exacty Commented Jul 18, 2016 at 12:37

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.