Skip to content

Object within object possible? #343

Closed
@mark-sp

Description

@mark-sp

Hi,

I just found out about json-schema specification and its PHP library and I am wondering whether the library supports nested JSON structures.

If so, I'd like to know how I have to set up my schema file to do the right validation. I've been following guidelines from json-schema docs with no problem so far, but I couldn't manage to make it work when one of the properties is itself an object: the validation is always OK although the elements within the inner object are not right.

Any idea of what I could be doing wrong? Is that a limitation of the library?

{
	"id": "http://yourdomain.com/schemas/schema.json",
	"title" : "Person",
	"type" : "object",
	"properties" : {
		"birthdate" : {
			"type" : "string",
			"format" : "date-time"
		},
		"gender" : {
			"type" : { "enum" : ["M", "F"] } 
		},
		"region" : {
			"type" : "string"
		},
		"province": {
			"type" : "string"
		},
		"phisical" : {
			"type" : "object",
			"properties" : {
				"weight" : {
					"type" : "integer",
					"minimum" : 0
				},
				"height" : {
					"type" : "integer",
					"minimum" : 0
				}
			}
		},

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions