This directory contains test assets used by all SDK implementations to ensure consistent validation behavior.
test-assets/
├── schemas/
│ ├── invalid/ # Invalid JSON Structure schemas (one edge case each)
│ │ ├── missing-type.struct.json
│ │ ├── unknown-type.struct.json
│ │ ├── required-missing-property.struct.json
│ │ └── ... (25 edge case schemas)
│ │
│ ├── warnings/ # Valid schemas that trigger warnings
│ │ ├── numeric-minimum-without-uses.struct.json
│ │ ├── string-pattern-without-uses.struct.json
│ │ ├── array-minitems-without-uses.struct.json
│ │ └── ... (21 warning test schemas)
│ │
│ └── validation/ # Schemas with $uses to test constraint enforcement
│ ├── numeric-minimum-with-uses.struct.json
│ ├── string-pattern-with-uses.struct.json
│ ├── array-minitems-with-uses.struct.json
│ └── ... (12 validation test schemas)
│
└── instances/
├── invalid/ # Invalid instances for sample schemas
│ ├── 01-basic-person/
│ ├── 02-address/
│ ├── 04-datetime-examples/
│ ├── 05-collections/
│ ├── 06-tuples/
│ └── 11-sets-and-maps/
│
└── validation/ # Invalid instances for validation schemas
├── numeric-minimum-with-uses/
├── string-pattern-with-uses/
├── all-extension-keywords-with-uses/
└── ... (matches schemas/validation/)
Each invalid schema file tests a specific edge case that should cause schema validation to fail:
| File | Edge Case |
|---|---|
missing-type.struct.json |
Object with properties but no type keyword |
unknown-type.struct.json |
Unrecognized type name |
required-missing-property.struct.json |
Required array references non-existent property |
ref-undefined.struct.json |
$ref points to undefined definition |
constraint-type-mismatch-minimum.struct.json |
minimum on string type |
constraint-type-mismatch-minlength.struct.json |
minLength on numeric type |
invalid-regex-pattern.struct.json |
Malformed regular expression |
minlength-exceeds-maxlength.struct.json |
minLength > maxLength |
minimum-exceeds-maximum.struct.json |
minimum > maximum |
minitems-exceeds-maxitems.struct.json |
minItems > maxItems |
required-not-array.struct.json |
required is string instead of array |
enum-not-array.struct.json |
enum is not an array |
enum-empty.struct.json |
Empty enum array |
multipleof-zero.struct.json |
multipleOf = 0 |
multipleof-negative.struct.json |
Negative multipleOf |
circular-ref-direct.struct.json |
Direct circular $ref |
tuple-missing-prefixitems.struct.json |
Tuple without prefixItems |
array-missing-items.struct.json |
Array without items |
map-missing-values.struct.json |
Map without values |
minlength-negative.struct.json |
Negative minLength |
minitems-negative.struct.json |
Negative minItems |
properties-not-object.struct.json |
properties is not an object |
defs-not-object.struct.json |
definitions is an array |
allof-not-array.struct.json |
allOf is not an array |
enum-duplicates.struct.json |
Duplicate values in enum |
Each warning schema file tests a specific case where a validation extension keyword is used without enabling the validation extension via $uses: ["JSONStructureValidation"]. These schemas are valid but should produce warnings:
| File | Extension Keyword |
|---|---|
numeric-minimum-without-uses.struct.json |
minimum |
numeric-maximum-without-uses.struct.json |
maximum |
numeric-exclusive-minimum-without-uses.struct.json |
exclusiveMinimum |
numeric-exclusive-maximum-without-uses.struct.json |
exclusiveMaximum |
numeric-multiple-of-without-uses.struct.json |
multipleOf |
string-minlength-without-uses.struct.json |
minLength |
string-pattern-without-uses.struct.json |
pattern |
string-format-without-uses.struct.json |
format |
array-minitems-without-uses.struct.json |
minItems |
array-maxitems-without-uses.struct.json |
maxItems |
array-uniqueitems-without-uses.struct.json |
uniqueItems |
array-contains-without-uses.struct.json |
contains |
array-mincontains-without-uses.struct.json |
minContains |
array-maxcontains-without-uses.struct.json |
maxContains |
object-minproperties-without-uses.struct.json |
minProperties |
object-maxproperties-without-uses.struct.json |
maxProperties |
object-dependentrequired-without-uses.struct.json |
dependentRequired |
object-patternproperties-without-uses.struct.json |
patternProperties |
object-propertynames-without-uses.struct.json |
propertyNames |
all-extension-keywords-without-uses.struct.json |
All keywords (13 warnings) |
all-extension-keywords-with-uses.struct.json |
All keywords with $uses (no warnings) |
These schemas enable the validation extension via $uses: ["JSONStructureValidation"] to test that extension keywords ARE enforced when properly enabled. Each schema has corresponding invalid instances in instances/validation/:
| Schema | Keyword Tested | Invalid Instance |
|---|---|---|
numeric-minimum-with-uses.struct.json |
minimum |
Value below minimum |
numeric-maximum-with-uses.struct.json |
maximum |
Value above maximum |
numeric-exclusive-minimum-with-uses.struct.json |
exclusiveMinimum |
Value at exclusive minimum |
numeric-exclusive-maximum-with-uses.struct.json |
exclusiveMaximum |
Value at exclusive maximum |
numeric-multiple-of-with-uses.struct.json |
multipleOf |
Value not a multiple |
string-minlength-with-uses.struct.json |
minLength |
String too short |
string-pattern-with-uses.struct.json |
pattern |
String doesn't match pattern |
array-minitems-with-uses.struct.json |
minItems |
Array has too few items |
array-maxitems-with-uses.struct.json |
maxItems |
Array has too many items |
object-minproperties-with-uses.struct.json |
minProperties |
Object has too few properties |
object-maxproperties-with-uses.struct.json |
maxProperties |
Object has too many properties |
all-extension-keywords-with-uses.struct.json |
All keywords | Multiple violation instances |
Each subdirectory corresponds to a sample schema from primer-and-samples/samples/core/. Invalid instances test validation edge cases:
missing-required-firstname.json- Missing required fieldage-exceeds-int8-range.json- int8 value > 127wrong-type-age.json- String instead of int8invalid-date-format.json- Non-ISO date string
missing-required-city.json- Missing required fieldinvalid-country-enum.json- Value not in enumstreet-exceeds-maxlength.json- String > maxLength
invalid-datetime-format.json- Invalid datetime stringinvalid-uuid-format.json- Invalid UUID formatinvalid-duration-format.json- Non-ISO durationinvalid-frequency-enum.json- Value not in enum
set-with-duplicates.json- Duplicate values in setinvalid-uri-in-array.json- Invalid URI formatwrong-type-in-map-values.json- Number instead of string in map
tuple-wrong-length.json- Tuple has incorrect element counttuple-wrong-element-type.json- Wrong type at tuple positionuint8-exceeds-range.json- uint8 value > 255
genre-not-in-enum.json- Genre value not in enuminvalid-time-format.json- Non-ISO time formataccess-level-not-in-enum.json- Access level not in enum
SDK implementations should:
- Load all schemas from
schemas/invalid/and verify each fails validation - Load instances from
instances/invalid/along with their corresponding sample schemas - Verify each instance fails validation against its schema
Example test structure:
def test_invalid_schemas():
for schema_file in glob("test-assets/schemas/invalid/*.json"):
result = validate_schema(load(schema_file))
assert not result.is_valid
def test_invalid_instances():
for instance_file in glob("test-assets/instances/invalid/**/*.json"):
schema_name = instance_file.parent.name # e.g., "01-basic-person"
schema = load(f"samples/core/{schema_name}/schema.struct.json")
instance = load(instance_file)
result = validate_instance(instance, schema)
assert not result.is_valid