parent
c8a1d51753
commit
f586edd33d
@ -290,6 +290,7 @@ struct SchemaValidationContext {
|
|||||||
patternPropertiesSchemaCount(),
|
patternPropertiesSchemaCount(),
|
||||||
valuePatternValidatorType(kPatternValidatorOnly),
|
valuePatternValidatorType(kPatternValidatorOnly),
|
||||||
objectDependencies(),
|
objectDependencies(),
|
||||||
|
objectRequired(),
|
||||||
inArray(false),
|
inArray(false),
|
||||||
valueUniqueness(false),
|
valueUniqueness(false),
|
||||||
arrayUniqueness(false)
|
arrayUniqueness(false)
|
||||||
@ -313,6 +314,8 @@ struct SchemaValidationContext {
|
|||||||
factory.FreeState(patternPropertiesSchemas);
|
factory.FreeState(patternPropertiesSchemas);
|
||||||
if (objectDependencies)
|
if (objectDependencies)
|
||||||
factory.FreeState(objectDependencies);
|
factory.FreeState(objectDependencies);
|
||||||
|
if (objectRequired)
|
||||||
|
factory.FreeState(objectRequired);
|
||||||
}
|
}
|
||||||
|
|
||||||
SchemaValidatorFactoryType& factory;
|
SchemaValidatorFactoryType& factory;
|
||||||
@ -329,9 +332,9 @@ struct SchemaValidationContext {
|
|||||||
SizeType patternPropertiesSchemaCount;
|
SizeType patternPropertiesSchemaCount;
|
||||||
PatternValidatorType valuePatternValidatorType;
|
PatternValidatorType valuePatternValidatorType;
|
||||||
PatternValidatorType objectPatternValidatorType;
|
PatternValidatorType objectPatternValidatorType;
|
||||||
SizeType objectRequiredCount;
|
|
||||||
SizeType arrayElementIndex;
|
SizeType arrayElementIndex;
|
||||||
bool* objectDependencies;
|
bool* objectDependencies;
|
||||||
|
bool* objectRequired;
|
||||||
bool inArray;
|
bool inArray;
|
||||||
bool valueUniqueness;
|
bool valueUniqueness;
|
||||||
bool arrayUniqueness;
|
bool arrayUniqueness;
|
||||||
@ -365,11 +368,11 @@ public:
|
|||||||
patternProperties_(),
|
patternProperties_(),
|
||||||
patternPropertyCount_(),
|
patternPropertyCount_(),
|
||||||
propertyCount_(),
|
propertyCount_(),
|
||||||
requiredCount_(),
|
|
||||||
minProperties_(),
|
minProperties_(),
|
||||||
maxProperties_(SizeType(~0)),
|
maxProperties_(SizeType(~0)),
|
||||||
additionalProperties_(true),
|
additionalProperties_(true),
|
||||||
hasDependencies_(),
|
hasDependencies_(),
|
||||||
|
hasRequired_(),
|
||||||
hasSchemaDependencies_(),
|
hasSchemaDependencies_(),
|
||||||
additionalItemsSchema_(),
|
additionalItemsSchema_(),
|
||||||
itemsList_(),
|
itemsList_(),
|
||||||
@ -490,7 +493,7 @@ public:
|
|||||||
SizeType index;
|
SizeType index;
|
||||||
if (FindPropertyIndex(*itr, &index)) {
|
if (FindPropertyIndex(*itr, &index)) {
|
||||||
properties_[index].required = true;
|
properties_[index].required = true;
|
||||||
requiredCount_++;
|
hasRequired_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -767,7 +770,11 @@ public:
|
|||||||
if (!(type_ & (1 << kObjectSchemaType)))
|
if (!(type_ & (1 << kObjectSchemaType)))
|
||||||
RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());
|
RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());
|
||||||
|
|
||||||
context.objectRequiredCount = 0;
|
if (hasRequired_) {
|
||||||
|
context.objectRequired = static_cast<bool*>(context.factory.MallocState(sizeof(bool) * propertyCount_));
|
||||||
|
std::memset(context.objectRequired, 0, sizeof(bool) * propertyCount_);
|
||||||
|
}
|
||||||
|
|
||||||
if (hasDependencies_) {
|
if (hasDependencies_) {
|
||||||
context.objectDependencies = static_cast<bool*>(context.factory.MallocState(sizeof(bool) * propertyCount_));
|
context.objectDependencies = static_cast<bool*>(context.factory.MallocState(sizeof(bool) * propertyCount_));
|
||||||
std::memset(context.objectDependencies, 0, sizeof(bool) * propertyCount_);
|
std::memset(context.objectDependencies, 0, sizeof(bool) * propertyCount_);
|
||||||
@ -801,8 +808,8 @@ public:
|
|||||||
else
|
else
|
||||||
context.valueSchema = properties_[index].schema;
|
context.valueSchema = properties_[index].schema;
|
||||||
|
|
||||||
if (properties_[index].required)
|
if (hasRequired_)
|
||||||
context.objectRequiredCount++;
|
context.objectRequired[index] = true;
|
||||||
|
|
||||||
if (hasDependencies_)
|
if (hasDependencies_)
|
||||||
context.objectDependencies[index] = true;
|
context.objectDependencies[index] = true;
|
||||||
@ -832,8 +839,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool EndObject(Context& context, SizeType memberCount) const {
|
bool EndObject(Context& context, SizeType memberCount) const {
|
||||||
if (context.objectRequiredCount != requiredCount_)
|
if (hasRequired_)
|
||||||
RAPIDJSON_INVALID_KEYWORD_RETURN(GetRequiredString());
|
for (SizeType index = 0; index < propertyCount_; index++) {
|
||||||
|
if (properties_[index].required)
|
||||||
|
if (!context.objectRequired[index])
|
||||||
|
RAPIDJSON_INVALID_KEYWORD_RETURN(GetRequiredString());
|
||||||
|
}
|
||||||
|
|
||||||
if (memberCount < minProperties_)
|
if (memberCount < minProperties_)
|
||||||
RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinPropertiesString());
|
RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinPropertiesString());
|
||||||
@ -1236,11 +1247,11 @@ private:
|
|||||||
PatternProperty* patternProperties_;
|
PatternProperty* patternProperties_;
|
||||||
SizeType patternPropertyCount_;
|
SizeType patternPropertyCount_;
|
||||||
SizeType propertyCount_;
|
SizeType propertyCount_;
|
||||||
SizeType requiredCount_;
|
|
||||||
SizeType minProperties_;
|
SizeType minProperties_;
|
||||||
SizeType maxProperties_;
|
SizeType maxProperties_;
|
||||||
bool additionalProperties_;
|
bool additionalProperties_;
|
||||||
bool hasDependencies_;
|
bool hasDependencies_;
|
||||||
|
bool hasRequired_;
|
||||||
bool hasSchemaDependencies_;
|
bool hasSchemaDependencies_;
|
||||||
|
|
||||||
const SchemaType* additionalItemsSchema_;
|
const SchemaType* additionalItemsSchema_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user