Open Lighting Architecture: ola::web::ObjectValidator Class Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
ola::web::ObjectValidator Class Reference
JSON

## Detailed Description

The validator for JsonObject.

Note
  This does not implement patternProperties. This is done because we don't want to pull in a regex library just yet. Maybe some point in the future we can use re2.

Inheritance diagram for ola::web::ObjectValidator:

## Classes
struct | Options

## Public Member Functions
| ObjectValidator (const Options &options)
void | AddValidator (const std::string &property, ValidatorInterface *validator)
| Add a validator for a property.
void | SetAdditionalValidator (ValidatorInterface *validator)
| Add the validator for additionalProperties.
void | AddSchemaDependency (const std::string &property, ValidatorInterface *validator)
| Add a schema dependency.
void | AddPropertyDependency (const std::string &property, const std::set< std::string > &properties)
| Add a property dependency.
void | Visit (const JsonObject &obj)
void | VisitProperty (const std::string &property, const JsonValue &value)
| Visit the value at the given property.
Public Member Functions inherited from ola::web::BaseValidator
virtual bool | IsValid () const
| Check if the value was valid according to this validator.
virtual void | Visit (const JsonString &)
virtual void | Visit (const JsonBool &)
virtual void | Visit (const JsonNull &)
virtual void | Visit (const JsonRawValue &)
virtual void | Visit (const JsonArray &)
virtual void | Visit (const JsonUInt &)
virtual void | Visit (const JsonUInt64 &)
virtual void | Visit (const JsonInt &)
virtual void | Visit (const JsonInt64 &)
virtual void | Visit (const JsonDouble &)
virtual JsonObject * | GetSchema () const
| Returns the Schema as a JsonObject.
void | SetSchema (const std::string &schema)
| Set the schema.
void | SetId (const std::string &id)
| Set the id.
void | SetTitle (const std::string &title)
| Set the title.
void | SetDescription (const std::string &title)
| Set the description.
void | SetDefaultValue (const JsonValue *value)
| Set the default value for this validator.
const JsonValue * | GetDefaultValue () const
| Return the default value.
void | AddEnumValue (const JsonValue *value)
| Add a enum value to the list of allowed values.

## Additional Inherited Members
Public Types inherited from ola::web::ValidatorInterface
typedef std::vector< ValidatorInterface * > | ValidatorList
| a list of Validators.
Protected Member Functions inherited from ola::web::BaseValidator
| BaseValidator (JsonType type)
bool | CheckEnums (const JsonValue &value)
Protected Attributes inherited from ola::web::BaseValidator
bool | m_is_valid
JsonType | m_type
std::string | m_schema
std::string | m_id
std::string | m_title
std::string | m_description
std::auto_ptr< const JsonValue > | m_default_value
std::vector< const JsonValue * > | m_enums

## Member Function Documentation

## ◆ AddPropertyDependency()

void ola::web::ObjectValidator::AddPropertyDependency | ( | const std::string & | property,
|  | const std::set< std::string > & | properties )

Add a property dependency.

Parameters

  property | the property name
  properties | the names of the properties that must exist in the object if the named property is present.

As per Section 5.4.5.2.2, if the named property is present in the object, the object must also contain all of the properties in the set.

## ◆ AddSchemaDependency()

void ola::web::ObjectValidator::AddSchemaDependency | ( | const std::string & | property,
|  | ValidatorInterface * | validator )

Add a schema dependency.

Parameters

  property | the property name
  validator | the validator to check the object against. Ownership is transferred.

As per Section 5.4.5.2.1, if the named property is present in the object, the object itself will be validated against the supplied schema.

## ◆ AddValidator()

void ola::web::ObjectValidator::AddValidator | ( | const std::string & | property,
|  | ValidatorInterface * | validator )

Add a validator for a property.

Parameters

  property | the name of the property to use this validator for
  validator | the validator, ownership is transferred.

## ◆ SetAdditionalValidator()

void ola::web::ObjectValidator::SetAdditionalValidator | ( | ValidatorInterface * | validator | ) |

Add the validator for additionalProperties.

Parameters

  validator | the validator, ownership is transferred.

## ◆ Visit()

void ola::web::ObjectValidator::Visit | ( | const JsonObject & | obj | ) |
| virtual

Reimplemented from ola::web::BaseValidator.

## ◆ VisitProperty()

void ola::web::ObjectValidator::VisitProperty | ( | const std::string & | property,
|  | const JsonValue & | value )
| virtual

Visit the value at the given property.

Implements ola::web::JsonObjectPropertyVisitor.

The documentation for this class was generated from the following files:

- include/ola/web/JsonSchema.h
- common/web/JsonSchema.cpp