diff --git a/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithMaxItems.st b/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithMaxItems.st new file mode 100644 index 0000000..77f71af --- /dev/null +++ b/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithMaxItems.st @@ -0,0 +1,12 @@ +tests +testArrayWithMaxItems + | schema value | + schema := JSONSchema fromString: '{ + "type": "array", + "items": {"type": "string"}, + "maxItems": 2 +}'. + self + shouldnt: [ value := schema validate: { 'bar' } ] + raise: Error. + diff --git a/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithMaxItemsFail.st b/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithMaxItemsFail.st new file mode 100644 index 0000000..58d7537 --- /dev/null +++ b/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithMaxItemsFail.st @@ -0,0 +1,12 @@ +tests +testArrayWithMaxItemsFail + | schema value | + schema := JSONSchema fromString: '{ + "type": "array", + "items": {"type": "string"}, + "maxItems": 2 +}'. + self + should: [ value := schema validate: { 'bar'. 'foo' . 'baz' } ] + raise: Error. + diff --git a/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithMinItems.st b/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithMinItems.st new file mode 100644 index 0000000..f2aea6e --- /dev/null +++ b/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithMinItems.st @@ -0,0 +1,12 @@ +tests +testArrayWithMinItems + | schema value | + schema := JSONSchema fromString: '{ + "type": "array", + "items": {"type": "string"}, + "minItems": 1 +}'. + self + shouldnt: [ value := schema validate: { 'bar' } ] + raise: Error. + diff --git a/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithMinItemsFail.st b/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithMinItemsFail.st new file mode 100644 index 0000000..5e071f4 --- /dev/null +++ b/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithMinItemsFail.st @@ -0,0 +1,12 @@ +tests +testArrayWithMinItemsFail + | schema value | + schema := JSONSchema fromString: '{ + "type": "array", + "items": {"type": "string"}, + "minItems": 2 +}'. + self + should: [ value := schema validate: { 'foo' } ] + raise: Error. + diff --git a/source/JSONSchema-Core-Tests.package/JSONTypeTests.class/instance/testReadArrayWithEmptyItems.st b/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithNoItemsSpec.st similarity index 92% rename from source/JSONSchema-Core-Tests.package/JSONTypeTests.class/instance/testReadArrayWithEmptyItems.st rename to source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithNoItemsSpec.st index d981782..939c8f3 100644 --- a/source/JSONSchema-Core-Tests.package/JSONTypeTests.class/instance/testReadArrayWithEmptyItems.st +++ b/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testArrayWithNoItemsSpec.st @@ -1,5 +1,5 @@ tests -testReadArrayWithEmptyItems +testArrayWithNoItemsSpec | schema value | schema := JSONSchema fromString: '{"type": "array"}'. self diff --git a/source/JSONSchema-Core-Tests.package/JSONTypeTests.class/instance/testReadNoTypeWithConstraints.st b/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testNoTypeWithConstraints.st similarity index 83% rename from source/JSONSchema-Core-Tests.package/JSONTypeTests.class/instance/testReadNoTypeWithConstraints.st rename to source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testNoTypeWithConstraints.st index 44e0783..ce096a6 100644 --- a/source/JSONSchema-Core-Tests.package/JSONTypeTests.class/instance/testReadNoTypeWithConstraints.st +++ b/source/JSONSchema-Core-Tests.package/JSONSchemaDefinitionTests.class/instance/testNoTypeWithConstraints.st @@ -1,5 +1,5 @@ tests -testReadNoTypeWithConstraints +testNoTypeWithConstraints | schema | schema := JSONSchema fromString: '{"exclusiveMaximum":10}'. diff --git a/source/JSONSchema-Core.package/JSONFormatDate.class/class/validate..st b/source/JSONSchema-Core.package/JSONFormatDate.class/class/validate..st new file mode 100644 index 0000000..afafa93 --- /dev/null +++ b/source/JSONSchema-Core.package/JSONFormatDate.class/class/validate..st @@ -0,0 +1,6 @@ +services +validate: aDate + (aDate isKindOf: Date) ifFalse: [ + JSONTypeError + signal: aDate printString , ' is not a date' ] + \ No newline at end of file diff --git a/source/JSONSchema-Core.package/JSONFormatDateTime.class/class/validate..st b/source/JSONSchema-Core.package/JSONFormatDateTime.class/class/validate..st new file mode 100644 index 0000000..b33204f --- /dev/null +++ b/source/JSONSchema-Core.package/JSONFormatDateTime.class/class/validate..st @@ -0,0 +1,6 @@ +services +validate: aDate + (aDate isKindOf: DateAndTime) ifFalse: [ + JSONTypeError + signal: aDate printString , ' is not a date' ] + \ No newline at end of file diff --git a/source/JSONSchema-Core.package/JSONFormatURI.class/class/validate..st b/source/JSONSchema-Core.package/JSONFormatURI.class/class/validate..st new file mode 100644 index 0000000..9679039 --- /dev/null +++ b/source/JSONSchema-Core.package/JSONFormatURI.class/class/validate..st @@ -0,0 +1,6 @@ +services +validate: aUrl + (aUrl isKindOf: ZnUrl) ifFalse: [ + JSONTypeError + signal: aUrl printString , ' is not a URL' ] + \ No newline at end of file diff --git a/source/JSONSchema-Core.package/JSONSchemaReference.class/instance/printOn..st b/source/JSONSchema-Core.package/JSONSchemaReference.class/instance/printOn..st new file mode 100644 index 0000000..f89f30e --- /dev/null +++ b/source/JSONSchema-Core.package/JSONSchemaReference.class/instance/printOn..st @@ -0,0 +1,3 @@ +printing +printOn: aStream + aStream << 'Reference: '<< path asString \ No newline at end of file diff --git a/source/JSONSchema-Core.package/JSONStringFormat.class/class/validate..st b/source/JSONSchema-Core.package/JSONStringFormat.class/class/validate..st new file mode 100644 index 0000000..bcdd2a5 --- /dev/null +++ b/source/JSONSchema-Core.package/JSONStringFormat.class/class/validate..st @@ -0,0 +1,6 @@ +services +validate: aString + aString isString ifFalse: [ + JSONTypeError + signal: aString printString , ' is not a string' ] + \ No newline at end of file diff --git a/source/JSONSchema-Core.package/JSONStringFormat.class/class/validateString..st b/source/JSONSchema-Core.package/JSONStringFormat.class/class/validateString..st new file mode 100644 index 0000000..ecd35e6 --- /dev/null +++ b/source/JSONSchema-Core.package/JSONStringFormat.class/class/validateString..st @@ -0,0 +1,6 @@ +services +validateString: aString + aString isString ifFalse: [ + JSONTypeError + signal: aString printString , ' is not a string' ] + \ No newline at end of file