Skip to content

Commit

Permalink
Merge pull request #40 from zweidenker/add-mintiems-maxitems-to-array
Browse files Browse the repository at this point in the history
Repaired string schema to test if string and added minItems, maxItems…
  • Loading branch information
noha authored Aug 4, 2020
2 parents 22397dd + 84ab674 commit 1d072bd
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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.

Original file line number Diff line number Diff line change
@@ -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.

Original file line number Diff line number Diff line change
@@ -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.

Original file line number Diff line number Diff line change
@@ -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.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tests
testReadArrayWithEmptyItems
testArrayWithNoItemsSpec
| schema value |
schema := JSONSchema fromString: '{"type": "array"}'.
self
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tests
testReadNoTypeWithConstraints
testNoTypeWithConstraints
| schema |
schema := JSONSchema fromString: '{"exclusiveMaximum":10}'.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services
validate: aDate
(aDate isKindOf: Date) ifFalse: [
JSONTypeError
signal: aDate printString , ' is not a date' ]

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services
validate: aDate
(aDate isKindOf: DateAndTime) ifFalse: [
JSONTypeError
signal: aDate printString , ' is not a date' ]

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services
validate: aUrl
(aUrl isKindOf: ZnUrl) ifFalse: [
JSONTypeError
signal: aUrl printString , ' is not a URL' ]

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
printing
printOn: aStream
aStream << 'Reference: '<< path asString
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services
validate: aString
aString isString ifFalse: [
JSONTypeError
signal: aString printString , ' is not a string' ]

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services
validateString: aString
aString isString ifFalse: [
JSONTypeError
signal: aString printString , ' is not a string' ]

0 comments on commit 1d072bd

Please sign in to comment.