|
|
@@ -1043,6 +1043,24 @@ ValidationResult* DataValidator::validate(ElementPath* pathToValidate,
|
|
|
}
|
|
|
}
|
|
|
const AbstractArray* array = zValue->asAbstractArray();
|
|
|
+ if (zConstraints->hasAttribute("minSize")
|
|
|
+ && (int)zConstraints->getAttributeValue("minSize")
|
|
|
+ > array->getLength())
|
|
|
+ {
|
|
|
+ return new TypeMissmatch(path,
|
|
|
+ dynamic_cast<AbstractElement*>(zValue->getThis()),
|
|
|
+ dynamic_cast<XML::Element*>(zConstraints->getThis()),
|
|
|
+ 0);
|
|
|
+ }
|
|
|
+ if (zConstraints->hasAttribute("maxSize")
|
|
|
+ && (int)zConstraints->getAttributeValue("maxSize")
|
|
|
+ < array->getLength())
|
|
|
+ {
|
|
|
+ return new TypeMissmatch(path,
|
|
|
+ dynamic_cast<AbstractElement*>(zValue->getThis()),
|
|
|
+ dynamic_cast<XML::Element*>(zConstraints->getThis()),
|
|
|
+ 0);
|
|
|
+ }
|
|
|
for (int i = 0; i < array->getLength(); i++)
|
|
|
{
|
|
|
Text p = path;
|
|
|
@@ -1058,7 +1076,6 @@ ValidationResult* DataValidator::validate(ElementPath* pathToValidate,
|
|
|
dynamic_cast<XML::Element*>(zConstraints->getThis()),
|
|
|
res);
|
|
|
}
|
|
|
- res->release();
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
@@ -1503,6 +1520,18 @@ JSON::JSONObject* Framework::Validator::DataValidator::getJsonSchema(
|
|
|
{
|
|
|
oneOf->addValue(getJsonSchema(e, zDefs));
|
|
|
}
|
|
|
+ if (zConstraint->hasAttribute("minSize"))
|
|
|
+ {
|
|
|
+ result->addValue("minItems",
|
|
|
+ new JSON::JSONNumber(
|
|
|
+ (double)zConstraint->getAttributeValue("minSize")));
|
|
|
+ }
|
|
|
+ if (zConstraint->hasAttribute("maxSize"))
|
|
|
+ {
|
|
|
+ result->addValue("maxItems",
|
|
|
+ new JSON::JSONNumber(
|
|
|
+ (double)zConstraint->getAttributeValue("maxSize")));
|
|
|
+ }
|
|
|
items->addValue("oneOf", oneOf);
|
|
|
result->addValue("items", items);
|
|
|
}
|