package jsonschema-core
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page
JSON Schema core: $ref resolution, JSON Pointer, instance model
Install
dune-project
Dependency
Authors
Maintainers
Sources
v0.1.0.tar.gz
md5=71c7ff547793b732ad58ca96160b00ff
sha512=5d5f7d1751e9e614d8b17017ceb97033642bf8aafeb167ad73123fcd770d400b66657c6938e5b367e070fe4ac239d1038abd49003c5329bb1b274e97320e32bb
doc/README.html
ocaml-jsonschema
JSON Schema draft-07 validator for OCaml.
Pure OCaml implementation. Compiles schemas into validator functions for repeated use.
Packages
- jsonschema-core —
$refresolution, JSON Pointer, registry, regex engine, instance model - jsonschema-validation — All 37 draft-07 validation keywords + 17 format validators
Installation
opam pin add jsonschema-core .
opam pin add jsonschema-validation .Usage
let schema = Yojson.Safe.from_string {|{
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "integer", "minimum": 0 }
},
"required": ["name"]
}|}
let validate = Jsonschema_validation.compile schema
let () =
let data = Yojson.Safe.from_string {|{"name": "Alice", "age": 30}|} in
match validate data with
| [] -> print_endline "valid"
| errors -> List.iter (fun e -> print_endline (Jsonschema_core.Error.to_string e)) errorsValidation keywords
- Type: type, enum, const
- Numeric: multipleOf, maximum, exclusiveMaximum, minimum, exclusiveMinimum
- String: maxLength, minLength, pattern
- Array: items, additionalItems, maxItems, minItems, uniqueItems, contains
- Object: properties, patternProperties, additionalProperties, maxProperties, minProperties, required, dependencies, dependentRequired, propertyNames
- Logic: allOf, anyOf, oneOf, not
- Conditional: if/then/else
- Format: date-time, date, time, email, idn-email, hostname, idn-hostname, uri, uri-reference, iri, iri-reference, uri-template, ipv4, ipv6, json-pointer, relative-json-pointer, regex
- Content: contentEncoding (base64), contentMediaType (application/json)
Format validation
Format validators cover RFC 3339 (date/time with leap second UTC conversion), RFC 3986/3987 (URI/IRI with percent-encoding and port validation), RFC 5890/5891/5892/5893 (IDNA2008 hostnames via ocaml-idna), and RFC 5321 (email).
Test suite results
JSON-Schema-Test-Suite draft-07:
- Mandatory: 922/922 (100%)
- Format: 535/535 (100%)
- Optional: 98/118 (83.1%)
- Total: 1555/1575 (98.7%)
Known limitations
20 optional test failures related to ECMA-262 regex Unicode semantics. The re library (ocaml/ocaml-re) operates at byte level without Unicode codepoint support. Affected patterns: \D, \W, \S on multi-byte characters, \uXXXX escapes, UTF-16 surrogate pairs, and Unicode character classes in pattern/patternProperties. Tracking: ocaml-re#24, ocaml-re#592.
License
ISC
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page