diff --git a/tests/example-files/explicit-schema/positive/complex-toml/instance.toml b/tests/example-files/explicit-schema/positive/complex-toml/instance.toml new file mode 100644 index 000000000..b8efb1223 --- /dev/null +++ b/tests/example-files/explicit-schema/positive/complex-toml/instance.toml @@ -0,0 +1,89 @@ +[object] +# Comment + +string = "I'm a string." +multiline_string = '''I\'m +a multiline +string''' + +integer_1 = 1 +integer_2 = +1 +integer_3 = -1 + +float_1 = +1.0 +float_2 = 3.1415 +float_3 = -0.01 +float_4 = 5e+22 +float_5 = 1e06 +float_6 = -2E-2 +float_7 = 6.626e-34 +float_8 = 224_617.445_991_228 + +infinite_1 = inf +infinite_2 = +inf +infinite_3 = -inf + +not_a_number_1 = nan +not_a_number_2 = +nan +not_a_number_3 = -nan + +hexadecimal_1 = 0xDEADBEEF +hexadecimal_2 = 0xdeadbeef +hexadecimal_3 = 0xdead_beef + +octal_1 = 0o01234567 +octal_2 = 0o755 + +binary = 0b11010110 + +# The null doesn't exists in TOML, but getting a value from an object +# using a non existent key will be validated against the "null" type +# null = Nil # https://github.com/toml-lang/toml/issues/30 + +boolean_1 = true +boolean_2 = false + +# FIXME: dates can't be validated against { "type": "string", "format": "date" } +# because tomli converts them to datetime objects, must be defined as strings +# See https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.7.3.1 +offset_datetime_1 = 1979-05-27T07:32:00Z +offset_datetime_2 = 1979-05-27T00:32:00-07:00 +offset_datetime_3 = 1979-05-27T00:32:00.999999-07:00 +offset_datetime_4 = '1979-05-27T07:32:00Z' +offset_datetime_5 = '1979-05-27T00:32:00-07:00' +offset_datetime_6 = '1979-05-27T00:32:00.999999-07:00' + +local_datetime_1 = 1979-05-27T07:32:00 +local_datetime_2 = 1979-05-27T00:32:00.999999 +local_datetime_3 = '1979-05-27T07:32:00' +local_datetime_4 = '1979-05-27T00:32:00.999999' + +local_date_1 = 1979-05-27 +local_date_2 = '1979-05-27' + +local_time_1 = 07:32:00 +local_time_2 = 00:32:00.999999 +local_time_3 = '07:32:00' +local_time_4 = '00:32:00.999999' + +array_1 = ["a", 2, true] +array_2 = [ + "b", + 3.1, + false, +] + + [nested_object_1] + foo = "bar" + +nested_object_2 = { foo = "bar" } + +[[array_of_objects_1]] +foo = "bar" +[[array_of_objects_1]] +foo = "bar" + + [[nested_array_of_objects_1]] + foo = "bar" + [[nested_array_of_objects_1]] + foo = "bar" diff --git a/tests/example-files/explicit-schema/positive/complex-toml/schema.json b/tests/example-files/explicit-schema/positive/complex-toml/schema.json new file mode 100644 index 000000000..0b3a88303 --- /dev/null +++ b/tests/example-files/explicit-schema/positive/complex-toml/schema.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "type": "object", + "properties": { + "object": { + "type": "object", + "properties": { + "string": { "type": "string" }, + "multiline_string": { "type": "string" }, + "integer_1": { "type": "integer" }, + "integer_2": { "type": "integer" }, + "integer_3": { "type": "integer" }, + "float_1": { "type": "number" }, + "float_2": { "type": "number" }, + "float_3": { "type": "number" }, + "float_4": { "type": "number" }, + "float_5": { "type": "number" }, + "float_6": { "type": "number" }, + "float_7": { "type": "number" }, + "float_8": { "type": "number" }, + "infinite_1": { "type": "number" }, + "infinite_2": { "type": "number" }, + "infinite_3": { "type": "number" }, + "not_a_number_1": { "type": "number" }, + "not_a_number_2": { "type": "number" }, + "not_a_number_3": { "type": "number" }, + "hexadecimal_1": { "type": "number" }, + "hexadecimal_2": { "type": "number" }, + "hexadecimal_3": { "type": "number" }, + "octal_1": { "type": "number" }, + "octal_2": { "type": "number" }, + "binary": { "type": "number" }, + "null": { "type": "null" }, + "boolean_1": { "type": "boolean" }, + "boolean_2": { "type": "boolean" }, + "offset_datetime_4": { "type": "string", "format": "date-time" }, + "offset_datetime_5": { "type": "string", "format": "date-time" }, + "offset_datetime_6": { "type": "string", "format": "date-time" }, + "local_datetime_4": { "type": "string", "format": "date-time" }, + "local_datetime_5": { "type": "string", "format": "date-time" }, + "local_date_2": { "type": "string", "format": "date" }, + "local_time_3": { "type": "string", "format": "time" }, + "local_time_4": { "type": "string", "format": "duration" }, + "array_1": { "type": "array" }, + "array_2": { "type": "array" }, + "nested_object_1": { + "type": "object", + "properties": { "foo": { "type": "string" } } + }, + "nested_object_2": { + "type": "object", + "properties": { "foo": { "type": "string" } } + }, + "array_of_objects_1": { + "type": "array", + "items": { + "type": "object", + "properties": { "foo": { "type": "string" } } + } + }, + "nested_array_of_objects_1": { + "type": "array", + "items": { + "type": "object", + "properties": { "foo": { "type": "string" } } + } + } + } + } + } +} diff --git a/tests/example-files/explicit-schema/positive/simple-toml/instance.toml b/tests/example-files/explicit-schema/positive/simple-toml/instance.toml deleted file mode 100644 index cfce90af5..000000000 --- a/tests/example-files/explicit-schema/positive/simple-toml/instance.toml +++ /dev/null @@ -1,2 +0,0 @@ -[item] -title = "an item" diff --git a/tests/example-files/explicit-schema/positive/simple-toml/schema.json b/tests/example-files/explicit-schema/positive/simple-toml/schema.json deleted file mode 100644 index f0496a158..000000000 --- a/tests/example-files/explicit-schema/positive/simple-toml/schema.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema", - "type": "object", - "properties": { - "item": { - "type": "object", - "properties": { - "title": { "type": "string"} - } - } - } -}