|
@@ -1167,19 +1167,19 @@ JSONValidationResult* JSONValidator::validate(JSONValue* zValue, XML::Element* z
|
|
|
{
|
|
|
return new JSONTypeMissmatch(path, dynamic_cast<JSONValue*>(zValue->getThis()), dynamic_cast<XML::Element*>(zConstraints->getThis()), 0);
|
|
|
}
|
|
|
- else if (zConstraints->hasAttribute("lessOrEqual") && zValue->asNumber()->getNumber() > (double)zConstraints->getAttributeValue("lessOrEqual"))
|
|
|
+ if (zConstraints->hasAttribute("lessOrEqual") && zValue->asNumber()->getNumber() > (double)zConstraints->getAttributeValue("lessOrEqual"))
|
|
|
{
|
|
|
return new JSONTypeMissmatch(path, dynamic_cast<JSONValue*>(zValue->getThis()), dynamic_cast<XML::Element*>(zConstraints->getThis()), 0);
|
|
|
}
|
|
|
- else if (zConstraints->hasAttribute("greaterOrEqual") && zValue->asNumber()->getNumber() < (double)zConstraints->getAttributeValue("greaterOrEqual"))
|
|
|
+ if (zConstraints->hasAttribute("greaterOrEqual") && zValue->asNumber()->getNumber() < (double)zConstraints->getAttributeValue("greaterOrEqual"))
|
|
|
{
|
|
|
return new JSONTypeMissmatch(path, dynamic_cast<JSONValue*>(zValue->getThis()), dynamic_cast<XML::Element*>(zConstraints->getThis()), 0);
|
|
|
}
|
|
|
- else if (zConstraints->hasAttribute("less") && zValue->asNumber()->getNumber() >= (double)zConstraints->getAttributeValue("less"))
|
|
|
+ if (zConstraints->hasAttribute("less") && zValue->asNumber()->getNumber() >= (double)zConstraints->getAttributeValue("less"))
|
|
|
{
|
|
|
return new JSONTypeMissmatch(path, dynamic_cast<JSONValue*>(zValue->getThis()), dynamic_cast<XML::Element*>(zConstraints->getThis()), 0);
|
|
|
}
|
|
|
- else if (zConstraints->hasAttribute("greater") && zValue->asNumber()->getNumber() <= (double)zConstraints->getAttributeValue("greater"))
|
|
|
+ if (zConstraints->hasAttribute("greater") && zValue->asNumber()->getNumber() <= (double)zConstraints->getAttributeValue("greater"))
|
|
|
{
|
|
|
return new JSONTypeMissmatch(path, dynamic_cast<JSONValue*>(zValue->getThis()), dynamic_cast<XML::Element*>(zConstraints->getThis()), 0);
|
|
|
}
|
|
@@ -1196,18 +1196,36 @@ JSONValidationResult* JSONValidator::validate(JSONValue* zValue, XML::Element* z
|
|
|
{
|
|
|
return new JSONTypeMissmatch(path, dynamic_cast<JSONValue*>(zValue->getThis()), dynamic_cast<XML::Element*>(zConstraints->getThis()), 0);
|
|
|
}
|
|
|
- else if (zConstraints->hasAttribute("contains") && zValue->asString()->getString().hat(zConstraints->getAttributeValue("contains").getText()))
|
|
|
+ if (zConstraints->hasAttribute("contains") && zValue->asString()->getString().hat(zConstraints->getAttributeValue("contains").getText()))
|
|
|
{
|
|
|
return new JSONTypeMissmatch(path, dynamic_cast<JSONValue*>(zValue->getThis()), dynamic_cast<XML::Element*>(zConstraints->getThis()), 0);
|
|
|
}
|
|
|
- else if (zConstraints->hasAttribute("startsWith") && zValue->asString()->getString().positionVon(zConstraints->getAttributeValue("startsWith").getText()) == 0)
|
|
|
+ if (zConstraints->hasAttribute("startsWith") && zValue->asString()->getString().positionVon(zConstraints->getAttributeValue("startsWith").getText()) == 0)
|
|
|
{
|
|
|
return new JSONTypeMissmatch(path, dynamic_cast<JSONValue*>(zValue->getThis()), dynamic_cast<XML::Element*>(zConstraints->getThis()), 0);
|
|
|
}
|
|
|
- else if (zConstraints->hasAttribute("endsWith") && zValue->asString()->getString().positionVon(zConstraints->getAttributeValue("endsWith").getText()) == zValue->asString()->getString().getLength() - zConstraints->getAttributeValue("endsWith").getLength())
|
|
|
+ if (zConstraints->hasAttribute("endsWith") && zValue->asString()->getString().positionVon(zConstraints->getAttributeValue("endsWith").getText()) == zValue->asString()->getString().getLength() - zConstraints->getAttributeValue("endsWith").getLength())
|
|
|
{
|
|
|
return new JSONTypeMissmatch(path, dynamic_cast<JSONValue*>(zValue->getThis()), dynamic_cast<XML::Element*>(zConstraints->getThis()), 0);
|
|
|
}
|
|
|
+ if (zConstraints->hasAttribute("oneOf"))
|
|
|
+ {
|
|
|
+ JSONArray* array = Parser::getValue(zConstraints->getAttributeValue("oneOf"))->asArray();
|
|
|
+ bool ok = 0;
|
|
|
+ for (JSONValue* v : *array)
|
|
|
+ {
|
|
|
+ if (v->asString()->getString().istGleich(zValue->asString()->getString()))
|
|
|
+ {
|
|
|
+ ok = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ array->release();
|
|
|
+ if (!ok)
|
|
|
+ {
|
|
|
+ return new JSONTypeMissmatch(path, dynamic_cast<JSONValue*>(zValue->getThis()), dynamic_cast<XML::Element*>(zConstraints->getThis()), 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
case JSONType::ARRAY:
|
|
@@ -1253,7 +1271,6 @@ JSONValidationResult* JSONValidator::validate(JSONValue* zValue, XML::Element* z
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- bool isValueValid = 0;
|
|
|
JSONValidationResult* res = validateMultipleTypes(zValue->asObject()->zValue(i.val()), zConstraints->selectChildsByAttribute("name", i.val()).begin().val(), p);
|
|
|
if (!res->isValid())
|
|
|
{
|