Caffa  1.1.0
C++ Application Framework for Embedded Systems with introspection
Public Types | Public Member Functions | List of all members
caffa::FieldValidator< DataType > Class Template Referenceabstract

Used to validate the value of data fields Implementations need the the validate method as well as readFromJson and writeToJson. More...

#include <cafFieldValidator.h>

Inheritance diagram for caffa::FieldValidator< DataType >:
Inheritance graph
[legend]
Collaboration diagram for caffa::FieldValidator< DataType >:
Collaboration graph
[legend]

Public Types

using FailureSeverity = FieldValidatorInterface::FailureSeverity
 
- Public Types inherited from caffa::FieldValidatorInterface
enum class  FailureSeverity { VALIDATOR_WARNING , VALIDATOR_ERROR , VALIDATOR_CRITICAL }
 The severity of failure. Essentially tells the application how to treat a validator failure: VALIDATOR_WARNING -> user warning VALIDATOR_ERROR -> user error VALIDATOR_CRITICAL -> critical application failure.
 

Public Member Functions

 FieldValidator (FailureSeverity failureSeverity=FailureSeverity::VALIDATOR_ERROR)
 
virtual std::pair< bool, std::string > validate (const DataType &value) const =0
 Validate the value. More...
 
- Public Member Functions inherited from caffa::FieldValidatorInterface
 FieldValidatorInterface (FailureSeverity failureSeverity)
 Construct a new Field Validator Interface object. More...
 
virtual void readFromJson (const nlohmann::json &jsonFieldObject, const Serializer &serializer)=0
 Read the validator from JSON. More...
 
virtual void writeToJson (nlohmann::json &jsonFieldObject, const Serializer &serializer) const =0
 Write the validator to JSON. More...
 
FailureSeverity failureSeverity () const
 Get the severity of a failure of the validator. More...
 

Detailed Description

template<typename DataType>
class caffa::FieldValidator< DataType >

Used to validate the value of data fields Implementations need the the validate method as well as readFromJson and writeToJson.

Template Parameters
DataType

Member Function Documentation

◆ validate()

template<typename DataType >
virtual std::pair<bool, std::string> caffa::FieldValidator< DataType >::validate ( const DataType &  value) const
pure virtual

Validate the value.

Parameters
valueThe value to validate
Returns
true if the value is acceptable
false if not

Implemented in caffa::RangeValidator< DataType >.


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