Skip to content

Commit

Permalink
Merge pull request jsonrainbow#98 from alexmmm/fix-constraint-errors-…
Browse files Browse the repository at this point in the history
…getter

Fix constraint errors getter
  • Loading branch information
justinrainbow committed Aug 25, 2014
2 parents ac8a330 + 9d53caf commit f6c768d
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/JsonSchema/Constraints/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function addErrors(array $errors)
*/
public function getErrors()
{
return array_unique($this->errors, SORT_REGULAR);
return $this->errors;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/JsonSchema/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public function check($value, $schema = null, $path = null, $i = null)
$validator = new Schema($this->checkMode, $this->uriRetriever);
$validator->check($value, $schema);

$this->addErrors($validator->getErrors());
$this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
}
}
115 changes: 115 additions & 0 deletions tests/JsonSchema/Tests/Constraints/OfPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,121 @@ public function getInvalidTests()
),
),
),
array(
'{"prop1": [1,2]}',
'{
"type": "object",
"properties": {
"prop1": {
"oneOf": [
{
"type": "string",
"pattern": "^[a-z]*$"
},
{
"type": "string",
"pattern": "^[A-Z]*$"
}
]
}
}
}'
),
array(
'{"prop1": [1,2]}',
'{
"type": "object",
"properties": {
"prop1": {
"anyOf": [
{
"type": "string",
"pattern": "^[A-Z]*$"
}
]
}
}
}'
),
array(
'{"prop1": [1,2]}',
'{
"type": "object",
"properties": {
"prop1": {
"anyOf": [
{
"type": "number"
},
{
"type": "string",
"pattern": "^[A-Z]*$"
}
]
}
}
}'
),
array(
'{"prop1": [1,2]}',
'{
"type": "object",
"properties": {
"prop1": {
"anyOf": [
{
"type": "string"
},
{
"type": "string",
"pattern": "^[A-Z]*$"
}
]
}
}
}'
),
array(
'{"prop1": [1,2]}',
'{
"type": "object",
"properties": {
"prop1": {
"anyOf": [
{
"type": "string",
"pattern": "^[a-z]*$"
},
{
"type": "string",
"pattern": "^[A-Z]*$"
}
]
}
}
}'
),
array(
'{"prop1": [1,2]}',
'{
"type": "object",
"properties": {
"prop1": {
"anyOf": [
{
"type": "number"
},
{
"type": "string"
},
{
"type": "string"
}
]
}
}
}'
)
);
}
}

0 comments on commit f6c768d

Please sign in to comment.