Add placeholders for conditional constraint

This commit is contained in:
Tristan Penman 2019-08-22 22:12:40 +10:00
parent 0f9e8cacf8
commit 162f246e63
4 changed files with 32 additions and 0 deletions

View File

@ -116,6 +116,12 @@ private:
/// Collection of sub-schemas, at least one of which must be satisfied
Subschemas subschemas;
};
class ConditionalConstraint: public BasicConstraint<ConditionalConstraint>
{
public:
ConditionalConstraint() { }
};
/**
* @brief Represents a 'dependencies' constraint.

View File

@ -7,6 +7,7 @@ namespace constraints {
class AllOfConstraint;
class AnyOfConstraint;
class ConditionalConstraint;
class DependenciesConstraint;
class EnumConstraint;
class LinearItemsConstraint;
@ -39,6 +40,7 @@ protected:
// Shorten type names for derived classes outside of this namespace
typedef constraints::AllOfConstraint AllOfConstraint;
typedef constraints::AnyOfConstraint AnyOfConstraint;
typedef constraints::ConditionalConstraint ConditionalConstraint;
typedef constraints::DependenciesConstraint DependenciesConstraint;
typedef constraints::EnumConstraint EnumConstraint;
typedef constraints::LinearItemsConstraint LinearItemsConstraint;
@ -66,6 +68,7 @@ public:
virtual bool visit(const AllOfConstraint &) = 0;
virtual bool visit(const AnyOfConstraint &) = 0;
virtual bool visit(const ConditionalConstraint &) = 0;
virtual bool visit(const DependenciesConstraint &) = 0;
virtual bool visit(const EnumConstraint &) = 0;
virtual bool visit(const LinearItemsConstraint &) = 0;

View File

@ -1125,6 +1125,24 @@ private:
return constraint;
}
template<typename AdapterType>
constraints::ConditionalConstraint makeConditionalConstraint(
Schema &rootSchema,
const AdapterType &rootNode,
const AdapterType &ifNode,
const AdapterType &thenNode,
const AdapterType *elseNode,
const opt::optional<std::string> currentScope,
const std::string &nodePath,
const typename FunctionPtrs<AdapterType>::FetchDoc fetchDoc,
typename DocumentCache<AdapterType>::Type &docCache,
SchemaCache &schemaCache
) {
constraints::ConditionalConstraint constraint;
return constraint;
}
/**
* @brief Make a new DependenciesConstraint object
*

View File

@ -160,6 +160,11 @@ public:
return numValidated > 0;
}
virtual bool visit(const ConditionalConstraint &constraint)
{
return false;
}
/**
* @brief Validate current node against a 'dependencies' constraint
*