--------------------
name fails regex:

{'persons': [{'id': 'P:001', 'name': 'prince'}]}:

vException (expected=False: <class 'jsonschema.exceptions.ValidationError'>:
	'prince' does not match '^\\S+ \\S+'

Failed validating 'pattern' in schema['properties']['persons']['items']['properties']['name']:
    {'pattern': '^\\S+ \\S+', 'type': 'string'}

On instance['persons'][0]['name']:
    'prince'

--------------------
missing ID:

{'persons': [{'name': 'prince charming'}]}:

vException (expected=False: <class 'jsonschema.exceptions.ValidationError'>:
	'id' is a required property

Failed validating 'required' in schema['properties']['persons']['items']:
    {'additionalProperties': False,
     'description': 'A person, living or dead',
     'properties': {'addresses': {'items': {'$ref': '#/$defs/Address'},
                                  'type': 'array'},
                    'age_in_years': {'description': 'number of years since '
                                                    'birth',
                                     'maximum': 999,
                                     'minimum': 0,
                                     'type': 'integer'},
                    'aliases': {'items': {'type': 'string'},
                                'type': 'array'},
                    'has_birth_event': {'$ref': '#/$defs/BirthEvent'},
                    'has_employment_history': {'items': {'$ref': '#/$defs/EmploymentEvent'},
                                               'type': 'array'},
                    'has_familial_relationships': {'items': {'$ref': '#/$defs/FamilialRelationship'},
                                                   'type': 'array'},
                    'has_medical_history': {'items': {'$ref': '#/$defs/MedicalEvent'},
                                            'type': 'array'},
                    'id': {'type': 'string'},
                    'name': {'pattern': '^\\S+ \\S+', 'type': 'string'}},
     'required': ['id'],
     'title': 'Person',
     'type': 'object'}

On instance['persons'][0]:
    {'name': 'prince charming'}

--------------------
wrong datatype for age:

{'persons': [{'id': 'P', 'name': 'prince charming', 'age': '33'}]}:

vException (expected=False: <class 'jsonschema.exceptions.ValidationError'>:
	Additional properties are not allowed ('age' was unexpected)

Failed validating 'additionalProperties' in schema['properties']['persons']['items']:
    {'additionalProperties': False,
     'description': 'A person, living or dead',
     'properties': {'addresses': {'items': {'$ref': '#/$defs/Address'},
                                  'type': 'array'},
                    'age_in_years': {'description': 'number of years since '
                                                    'birth',
                                     'maximum': 999,
                                     'minimum': 0,
                                     'type': 'integer'},
                    'aliases': {'items': {'type': 'string'},
                                'type': 'array'},
                    'has_birth_event': {'$ref': '#/$defs/BirthEvent'},
                    'has_employment_history': {'items': {'$ref': '#/$defs/EmploymentEvent'},
                                               'type': 'array'},
                    'has_familial_relationships': {'items': {'$ref': '#/$defs/FamilialRelationship'},
                                                   'type': 'array'},
                    'has_medical_history': {'items': {'$ref': '#/$defs/MedicalEvent'},
                                            'type': 'array'},
                    'id': {'type': 'string'},
                    'name': {'pattern': '^\\S+ \\S+', 'type': 'string'}},
     'required': ['id'],
     'title': 'Person',
     'type': 'object'}

On instance['persons'][0]:
    {'age': '33', 'id': 'P', 'name': 'prince charming'}

--------------------
wrong datatype for name:

{'companies': [{'id': 'ROR:1', 'name': 5}]}:

vException (expected=False: <class 'jsonschema.exceptions.ValidationError'>:
	5 is not of type 'string'

Failed validating 'type' in schema['properties']['companies']['items']['properties']['name']:
    {'type': 'string'}

On instance['companies'][0]['name']:
    5

--------------------
missing required type field:

{'persons': [{'id': 'P:001', 'name': 'jane smith', 'has_familial_relationships': [{'related_to': 'P:002'}]}]}:

vException (expected=False: <class 'jsonschema.exceptions.ValidationError'>:
	'type' is a required property

Failed validating 'required' in schema['properties']['persons']['items']['properties']['has_familial_relationships']['items']:
    {'additionalProperties': False,
     'description': '',
     'properties': {'ended_at_time': {'format': 'date', 'type': 'string'},
                    'related_to': {'type': 'string'},
                    'started_at_time': {'format': 'date', 'type': 'string'},
                    'type': {'$ref': '#/$defs/FamilialRelationshipType'}},
     'required': ['type', 'related_to'],
     'title': 'FamilialRelationship',
     'type': 'object'}

On instance['persons'][0]['has_familial_relationships'][0]:
    {'related_to': 'P:002'}

--------------------
wrong enum:

{'persons': [{'id': 'P:001', 'name': 'jane smith', 'has_familial_relationships': [{'related_to': 'P:002', 'type': 'NON_EXISTENT_RELATION'}]}]}:
 SKIPPED
--------------------
age lower than threshold:

{'persons': [{'id': 'P', 'name': 'benjamin button', 'age_in_years': -5}]}:

vException (expected=False: <class 'jsonschema.exceptions.ValidationError'>:
	-5 is less than the minimum of 0

Failed validating 'minimum' in schema['properties']['persons']['items']['properties']['age_in_years']:
    {'description': 'number of years since birth',
     'maximum': 999,
     'minimum': 0,
     'type': 'integer'}

On instance['persons'][0]['age_in_years']:
    -5

--------------------
age higher than threshold:

{'persons': [{'id': 'P', 'name': 'dr who', 'age_in_years': 5000}]}:

vException (expected=False: <class 'jsonschema.exceptions.ValidationError'>:
	5000 is greater than the maximum of 999

Failed validating 'maximum' in schema['properties']['persons']['items']['properties']['age_in_years']:
    {'description': 'number of years since birth',
     'maximum': 999,
     'minimum': 0,
     'type': 'integer'}

On instance['persons'][0]['age_in_years']:
    5000

--------------------
additional properties is closed:

{'persons': [{'id': 'P', 'name': 'john smith', 'made_up_property': 'abc'}]}:

vException (expected=False: <class 'jsonschema.exceptions.ValidationError'>:
	Additional properties are not allowed ('made_up_property' was unexpected)

Failed validating 'additionalProperties' in schema['properties']['persons']['items']:
    {'additionalProperties': False,
     'description': 'A person, living or dead',
     'properties': {'addresses': {'items': {'$ref': '#/$defs/Address'},
                                  'type': 'array'},
                    'age_in_years': {'description': 'number of years since '
                                                    'birth',
                                     'maximum': 999,
                                     'minimum': 0,
                                     'type': 'integer'},
                    'aliases': {'items': {'type': 'string'},
                                'type': 'array'},
                    'has_birth_event': {'$ref': '#/$defs/BirthEvent'},
                    'has_employment_history': {'items': {'$ref': '#/$defs/EmploymentEvent'},
                                               'type': 'array'},
                    'has_familial_relationships': {'items': {'$ref': '#/$defs/FamilialRelationship'},
                                                   'type': 'array'},
                    'has_medical_history': {'items': {'$ref': '#/$defs/MedicalEvent'},
                                            'type': 'array'},
                    'id': {'type': 'string'},
                    'name': {'pattern': '^\\S+ \\S+', 'type': 'string'}},
     'required': ['id'],
     'title': 'Person',
     'type': 'object'}

On instance['persons'][0]:
    {'id': 'P', 'made_up_property': 'abc', 'name': 'john smith'}

--------------------
optional open properties:

{'persons': [{'id': 'P', 'name': 'john smith', 'made_up_property': 'abc'}]}:
 SKIPPED
--------------------
additional properties is closed on enclosing object:

{'persons': [{'id': 'P', 'name': 'john smith'}], 'made_up_property': 'abc'}:

vException (expected=False: <class 'jsonschema.exceptions.ValidationError'>:
	Additional properties are not allowed ('made_up_property' was unexpected)

Failed validating 'additionalProperties' in schema:
    {'$defs': {'Activity': {'additionalProperties': False,
                            'description': 'a provence-generating activity',
                            'properties': {'description': {'type': 'string'},
                                           'ended_at_time': {'format': 'date',
                                                             'type': 'string'},
                                           'id': {'type': 'string'},
                                           'started_at_time': {'format': 'date',
                                                               'type': 'string'},
                                           'used': {'type': 'string'},
                                           'was_associated_with': {'type': 'string'},
                                           'was_informed_by': {'type': 'string'}},
                            'required': ['id'],
                            'title': 'Activity',
                            'type': 'object'},
               'Address': {'additionalProperties': False,
                           'description': '',
                           'properties': {'city': {'type': 'string'},
                                          'street': {'type': 'string'}},
                           'required': [],
                           'title': 'Address',
                           'type': 'object'},
               'Agent': {'additionalProperties': False,
                         'description': 'a provence-generating agent',
                         'properties': {'acted_on_behalf_of': {'type': 'string'},
                                        'id': {'type': 'string'},
                                        'was_informed_by': {'type': 'string'}},
                         'required': ['id'],
                         'title': 'Agent',
                         'type': 'object'},
               'BirthEvent': {'additionalProperties': False,
                              'description': '',
                              'properties': {'ended_at_time': {'format': 'date',
                                                               'type': 'string'},
                                             'in_location': {'type': 'string'},
                                             'is_current': {'type': 'boolean'},
                                             'started_at_time': {'format': 'date',
                                                                 'type': 'string'}},
                              'required': [],
                              'title': 'BirthEvent',
                              'type': 'object'},
               'ClassWithSpaces': {'additionalProperties': False,
                                   'description': '',
                                   'properties': {'slot_with_space_1': {'type': 'string'}},
                                   'required': [],
                                   'title': 'ClassWithSpaces',
                                   'type': 'object'},
               'CodeSystem': {'additionalProperties': False,
                              'description': '',
                              'properties': {'id': {'type': 'string'},
                                             'name': {'type': 'string'}},
                              'required': ['id'],
                              'title': 'CodeSystem',
                              'type': 'object'},
               'CodeSystem__identifier_optional': {'additionalProperties': False,
                                                   'description': '',
                                                   'properties': {'id': {'type': 'string'},
                                                                  'name': {'type': 'string'}},
                                                   'required': [],
                                                   'title': 'CodeSystem',
                                                   'type': 'object'},
               'Company': {'additionalProperties': False,
                           'description': '',
                           'properties': {'aliases': {'items': {'type': 'string'},
                                                      'type': 'array'},
                                          'ceo': {'type': 'string'},
                                          'id': {'type': 'string'},
                                          'name': {'type': 'string'}},
                           'required': ['id'],
                           'title': 'Company',
                           'type': 'object'},
               'Concept': {'additionalProperties': False,
                           'description': '',
                           'properties': {'id': {'type': 'string'},
                                          'in_code_system': {'type': 'string'},
                                          'name': {'type': 'string'}},
                           'required': ['id'],
                           'title': 'Concept',
                           'type': 'object'},
               'Dataset': {'additionalProperties': False,
                           'description': '',
                           'properties': {'activities': {'items': {'$ref': '#/$defs/Activity'},
                                                         'type': 'array'},
                                          'code_systems': {'additionalProperties': {'$ref': '#/$defs/CodeSystem__identifier_optional'}},
                                          'companies': {'items': {'$ref': '#/$defs/Company'},
                                                        'type': 'array'},
                                          'persons': {'items': {'$ref': '#/$defs/Person'},
                                                      'type': 'array'}},
                           'required': [],
                           'title': 'Dataset',
                           'type': 'object'},
               'DiagnosisConcept': {'additionalProperties': False,
                                    'description': '',
                                    'properties': {'id': {'type': 'string'},
                                                   'in_code_system': {'type': 'string'},
                                                   'name': {'type': 'string'}},
                                    'required': ['id'],
                                    'title': 'DiagnosisConcept',
                                    'type': 'object'},
               'DiagnosisType': {'description': '',
                                 'enum': ['TODO'],
                                 'title': 'DiagnosisType',
                                 'type': 'string'},
               'EmploymentEvent': {'additionalProperties': False,
                                   'description': '',
                                   'properties': {'employed_at': {'type': 'string'},
                                                  'ended_at_time': {'format': 'date',
                                                                    'type': 'string'},
                                                  'is_current': {'type': 'boolean'},
                                                  'started_at_time': {'format': 'date',
                                                                      'type': 'string'},
                                                  'type': {'$ref': '#/$defs/EmploymentEventType'}},
                                   'required': [],
                                   'title': 'EmploymentEvent',
                                   'type': 'object'},
               'EmploymentEventType': {'description': 'codes for different '
                                                      'kinds of '
                                                      'employment/HR '
                                                      'related events',
                                       'enum': ['HIRE',
                                                'FIRE',
                                                'PROMOTION',
                                                'TRANSFER'],
                                       'title': 'EmploymentEventType',
                                       'type': 'string'},
               'Event': {'additionalProperties': False,
                         'description': '',
                         'properties': {'ended_at_time': {'format': 'date',
                                                          'type': 'string'},
                                        'is_current': {'type': 'boolean'},
                                        'started_at_time': {'format': 'date',
                                                            'type': 'string'}},
                         'required': [],
                         'title': 'Event',
                         'type': 'object'},
               'FakeClass': {'additionalProperties': False,
                             'description': '',
                             'properties': {'test_attribute': {'type': 'string'}},
                             'required': [],
                             'title': 'FakeClass',
                             'type': 'object'},
               'FamilialRelationship': {'additionalProperties': False,
                                        'description': '',
                                        'properties': {'ended_at_time': {'format': 'date',
                                                                         'type': 'string'},
                                                       'related_to': {'type': 'string'},
                                                       'started_at_time': {'format': 'date',
                                                                           'type': 'string'},
                                                       'type': {'$ref': '#/$defs/FamilialRelationshipType'}},
                                        'required': ['type', 'related_to'],
                                        'title': 'FamilialRelationship',
                                        'type': 'object'},
               'FamilialRelationshipType': {'description': '',
                                            'enum': ['SIBLING_OF',
                                                     'PARENT_OF',
                                                     'CHILD_OF'],
                                            'title': 'FamilialRelationshipType',
                                            'type': 'string'},
               'MarriageEvent': {'additionalProperties': False,
                                 'description': '',
                                 'properties': {'ended_at_time': {'format': 'date',
                                                                  'type': 'string'},
                                                'in_location': {'type': 'string'},
                                                'is_current': {'type': 'boolean'},
                                                'married_to': {'type': 'string'},
                                                'started_at_time': {'format': 'date',
                                                                    'type': 'string'}},
                                 'required': [],
                                 'title': 'MarriageEvent',
                                 'type': 'object'},
               'MedicalEvent': {'additionalProperties': False,
                                'description': '',
                                'properties': {'diagnosis': {'$ref': '#/$defs/DiagnosisConcept'},
                                               'ended_at_time': {'format': 'date',
                                                                 'type': 'string'},
                                               'in_location': {'type': 'string'},
                                               'is_current': {'type': 'boolean'},
                                               'procedure': {'$ref': '#/$defs/ProcedureConcept'},
                                               'started_at_time': {'format': 'date',
                                                                   'type': 'string'}},
                                'required': [],
                                'title': 'MedicalEvent',
                                'type': 'object'},
               'Organization': {'additionalProperties': False,
                                'description': '',
                                'properties': {'aliases': {'items': {'type': 'string'},
                                                           'type': 'array'},
                                               'id': {'type': 'string'},
                                               'name': {'type': 'string'}},
                                'required': ['id'],
                                'title': 'Organization',
                                'type': 'object'},
               'OtherCodes': {'description': '',
                              'enum': ['a b'],
                              'title': 'OtherCodes',
                              'type': 'string'},
               'Person': {'additionalProperties': False,
                          'description': 'A person, living or dead',
                          'properties': {'addresses': {'items': {'$ref': '#/$defs/Address'},
                                                       'type': 'array'},
                                         'age_in_years': {'description': 'number '
                                                                         'of '
                                                                         'years '
                                                                         'since '
                                                                         'birth',
                                                          'maximum': 999,
                                                          'minimum': 0,
                                                          'type': 'integer'},
                                         'aliases': {'items': {'type': 'string'},
                                                     'type': 'array'},
                                         'has_birth_event': {'$ref': '#/$defs/BirthEvent'},
                                         'has_employment_history': {'items': {'$ref': '#/$defs/EmploymentEvent'},
                                                                    'type': 'array'},
                                         'has_familial_relationships': {'items': {'$ref': '#/$defs/FamilialRelationship'},
                                                                        'type': 'array'},
                                         'has_medical_history': {'items': {'$ref': '#/$defs/MedicalEvent'},
                                                                 'type': 'array'},
                                         'id': {'type': 'string'},
                                         'name': {'pattern': '^\\S+ \\S+',
                                                  'type': 'string'}},
                          'required': ['id'],
                          'title': 'Person',
                          'type': 'object'},
               'Place': {'additionalProperties': False,
                         'description': '',
                         'properties': {'aliases': {'items': {'type': 'string'},
                                                    'type': 'array'},
                                        'id': {'type': 'string'},
                                        'name': {'type': 'string'}},
                         'required': ['id'],
                         'title': 'Place',
                         'type': 'object'},
               'ProcedureConcept': {'additionalProperties': False,
                                    'description': '',
                                    'properties': {'id': {'type': 'string'},
                                                   'in_code_system': {'type': 'string'},
                                                   'name': {'type': 'string'}},
                                    'required': ['id'],
                                    'title': 'ProcedureConcept',
                                    'type': 'object'},
               'Relationship': {'additionalProperties': False,
                                'description': '',
                                'properties': {'ended_at_time': {'format': 'date',
                                                                 'type': 'string'},
                                               'related_to': {'type': 'string'},
                                               'started_at_time': {'format': 'date',
                                                                   'type': 'string'},
                                               'type': {'type': 'string'}},
                                'required': [],
                                'title': 'Relationship',
                                'type': 'object'},
               'SubclassTest': {'additionalProperties': False,
                                'description': '',
                                'properties': {'slot_with_space_1': {'type': 'string'},
                                               'slot_with_space_2': {'$ref': '#/$defs/ClassWithSpaces'}},
                                'required': [],
                                'title': 'SubclassTest',
                                'type': 'object'}},
     '$id': 'https://w3id.org/linkml/tests/kitchen_sink',
     '$schema': 'http://json-schema.org/draft-07/schema#',
     'additionalProperties': False,
     'properties': {'activities': {'items': {'$ref': '#/$defs/Activity'},
                                   'type': 'array'},
                    'code_systems': {'additionalProperties': {'$ref': '#/$defs/CodeSystem__identifier_optional'}},
                    'companies': {'items': {'$ref': '#/$defs/Company'},
                                  'type': 'array'},
                    'persons': {'items': {'$ref': '#/$defs/Person'},
                                'type': 'array'}},
     'required': [],
     'title': 'kitchen_sink',
     'type': 'object'}

On instance:
    {'made_up_property': 'abc',
     'persons': [{'id': 'P', 'name': 'john smith'}]}

--------------------
non-multivalued address:

{'persons': [{'id': 'P', 'name': 'john smith', 'addresses': {'street': '1 foo street', 'city': 'foo city'}}]}:

vException (expected=False: <class 'jsonschema.exceptions.ValidationError'>:
	{'street': '1 foo street', 'city': 'foo city'} is not of type 'array'

Failed validating 'type' in schema['properties']['persons']['items']['properties']['addresses']:
    {'items': {'$ref': '#/$defs/Address'}, 'type': 'array'}

On instance['persons'][0]['addresses']:
    {'city': 'foo city', 'street': '1 foo street'}

--------------------
valid cardinality:

{'persons': [{'id': 'P', 'name': 'john smith', 'has_medical_history': [{'in_location': 'GEO:1234', 'diagnosis': {'id': 'CODE:D0001', 'name': 'headache'}}]}]}:
No Exception (expected=True: {'description': 'valid cardinality', 'skip': False, 'valid': True, 'dataset': {'persons': [{'id': 'P', 'name': 'john smith', 'has_medical_history': [{'in_location': 'GEO:1234', 'diagnosis': {'id': 'CODE:D0001', 'name': 'headache'}}]}]}}--------------------
multivalued value for singlevalued list:

{'persons': [{'id': 'P', 'name': 'john smith', 'has_medical_history': [{'in_location': 'GEO:1234', 'diagnosis': [{'id': 'CODE:D0001', 'name': 'headache'}]}]}]}:

vException (expected=False: <class 'jsonschema.exceptions.ValidationError'>:
	[{'id': 'CODE:D0001', 'name': 'headache'}] is not of type 'object'

Failed validating 'type' in schema['properties']['persons']['items']['properties']['has_medical_history']['items']['properties']['diagnosis']:
    {'additionalProperties': False,
     'description': '',
     'properties': {'id': {'type': 'string'},
                    'in_code_system': {'type': 'string'},
                    'name': {'type': 'string'}},
     'required': ['id'],
     'title': 'DiagnosisConcept',
     'type': 'object'}

On instance['persons'][0]['has_medical_history'][0]['diagnosis']:
    [{'id': 'CODE:D0001', 'name': 'headache'}]

--------------------
multivalued value for singlevalued list:

{'persons': [{'id': 'P', 'name': 'john smith', 'has_medical_history': [{'in_location': 'GEO:1234', 'diagnosis': {'id': 'CODE:D0001', 'name': ['headache', 'cough']}}]}]}:

vException (expected=False: <class 'jsonschema.exceptions.ValidationError'>:
	['headache', 'cough'] is not of type 'string'

Failed validating 'type' in schema['properties']['persons']['items']['properties']['has_medical_history']['items']['properties']['diagnosis']['properties']['name']:
    {'type': 'string'}

On instance['persons'][0]['has_medical_history'][0]['diagnosis']['name']:
    ['headache', 'cough']

--------------------
string used in place of object:

{'persons': [{'id': 'P', 'name': 'john smith', 'addresses': ['1 foo street, foo city']}]}:

vException (expected=False: <class 'jsonschema.exceptions.ValidationError'>:
	'1 foo street, foo city' is not of type 'object'

Failed validating 'type' in schema['properties']['persons']['items']['properties']['addresses']['items']:
    {'additionalProperties': False,
     'description': '',
     'properties': {'city': {'type': 'string'},
                    'street': {'type': 'string'}},
     'required': [],
     'title': 'Address',
     'type': 'object'}

On instance['persons'][0]['addresses'][0]:
    '1 foo street, foo city'

--------------------
inline used where reference expected:

{'activities': [{'id': 'A1', 'was_associated_with': {'id': 'Agent:987'}}]}:

vException (expected=False: <class 'jsonschema.exceptions.ValidationError'>:
	{'id': 'Agent:987'} is not of type 'string'

Failed validating 'type' in schema['properties']['activities']['items']['properties']['was_associated_with']:
    {'type': 'string'}

On instance['activities'][0]['was_associated_with']:
    {'id': 'Agent:987'}

--------------------
date format:

{'activities': [{'id': 'A1', 'started_at_time': 'not a real date'}]}:
 SKIPPED
