mirror of
https://github.com/tristanpenman/valijson.git
synced 2024-12-12 10:13:51 +01:00
Merge pull request #69 from drdavella/use-maybe
Fix places in adapter implementation where non-strict checks should be used
This commit is contained in:
commit
c19a02bff0
@ -757,7 +757,7 @@ public:
|
||||
{
|
||||
if (value.isBool()) {
|
||||
return true;
|
||||
} else if (value.isString()) {
|
||||
} else if (maybeString()) {
|
||||
std::string stringValue;
|
||||
if (value.getString(stringValue)) {
|
||||
if (stringValue.compare("true") == 0 || stringValue.compare("false") == 0) {
|
||||
@ -773,7 +773,7 @@ public:
|
||||
{
|
||||
if (value.isNumber()) {
|
||||
return true;
|
||||
} else if (value.isString()) {
|
||||
} else if (maybeString()) {
|
||||
std::string s;
|
||||
if (value.getString(s)) {
|
||||
const char *b = s.c_str();
|
||||
@ -790,7 +790,7 @@ public:
|
||||
{
|
||||
if (value.isInteger()) {
|
||||
return true;
|
||||
} else if (value.isString()) {
|
||||
} else if (maybeString()) {
|
||||
std::string s;
|
||||
if (value.getString(s)) {
|
||||
std::istringstream i(s);
|
||||
@ -810,7 +810,7 @@ public:
|
||||
{
|
||||
if (value.isNull()) {
|
||||
return true;
|
||||
} else if (value.isString()) {
|
||||
} else if (maybeString()) {
|
||||
std::string stringValue;
|
||||
if (value.getString(stringValue)) {
|
||||
if (stringValue.empty()) {
|
||||
@ -826,7 +826,7 @@ public:
|
||||
{
|
||||
if (value.isObject()) {
|
||||
return true;
|
||||
} else if (value.isArray()) {
|
||||
} else if (maybeArray()) {
|
||||
size_t arraySize;
|
||||
if (value.getArraySize(arraySize) && arraySize == 0) {
|
||||
return true;
|
||||
|
@ -1985,7 +1985,7 @@ private:
|
||||
constraints::RequiredConstraint constraint;
|
||||
|
||||
for (const AdapterType v : node.getArray()) {
|
||||
if (!v.isString()) {
|
||||
if (!v.maybeString()) {
|
||||
throw std::runtime_error("Expected required property name to "
|
||||
"be a string value");
|
||||
}
|
||||
@ -2028,7 +2028,7 @@ private:
|
||||
|
||||
TypeConstraint constraint;
|
||||
|
||||
if (node.isString()) {
|
||||
if (node.maybeString()) {
|
||||
const TypeConstraint::JsonType type =
|
||||
TypeConstraint::jsonTypeFromString(node.getString());
|
||||
|
||||
@ -2039,10 +2039,10 @@ private:
|
||||
|
||||
constraint.addNamedType(type);
|
||||
|
||||
} else if (node.isArray()) {
|
||||
} else if (node.maybeArray()) {
|
||||
int index = 0;
|
||||
for (const AdapterType v : node.getArray()) {
|
||||
if (v.isString()) {
|
||||
if (v.maybeString()) {
|
||||
const TypeConstraint::JsonType type =
|
||||
TypeConstraint::jsonTypeFromString(v.getString());
|
||||
|
||||
@ -2054,7 +2054,7 @@ private:
|
||||
|
||||
constraint.addNamedType(type);
|
||||
|
||||
} else if (v.isObject() && version == kDraft3) {
|
||||
} else if (v.maybeObject() && version == kDraft3) {
|
||||
const std::string childPath = nodePath + "/" +
|
||||
std::to_string(index);
|
||||
const Subschema *subschema = makeOrReuseSchema<AdapterType>(
|
||||
@ -2069,7 +2069,7 @@ private:
|
||||
index++;
|
||||
}
|
||||
|
||||
} else if (node.isObject() && version == kDraft3) {
|
||||
} else if (node.maybeObject() && version == kDraft3) {
|
||||
const Subschema *subschema = makeOrReuseSchema<AdapterType>(
|
||||
rootSchema, rootNode, node, currentScope, nodePath,
|
||||
fetchDoc, NULL, NULL, docCache, schemaCache);
|
||||
|
Loading…
Reference in New Issue
Block a user