$darkmode
fable::schema::Interface Class Referenceabstract

#include <interface.hpp>

Inheritance diagram for fable::schema::Interface:

Public Member Functions

virtual std::unique_ptr< Interfaceclone () const =0
 
virtual bool is_variant () const
 
virtual JsonType type () const =0
 
virtual std::string type_string () const =0
 
virtual bool is_required () const =0
 
virtual const std::string & description () const =0
 
virtual void set_description (std::string s)=0
 
virtual Json usage () const =0
 
virtual Json json_schema () const =0
 
virtual bool validate (const Conf &c, std::optional< SchemaError > &error) const =0
 
virtual void validate_or_throw (const Conf &c) const final
 
virtual std::optional< SchemaErrorfail (const Conf &c) const final
 
virtual bool is_valid (const Conf &c) const final
 
virtual Json to_json () const
 
virtual void to_json (Json &) const =0
 
virtual void from_conf (const Conf &)=0
 
virtual void reset_ptr ()=0
 

Protected Member Functions

 Interface (const Interface &)=default
 
 Interface (Interface &&) noexcept=default
 
Interfaceoperator= (const Interface &)=default
 
Interfaceoperator= (Interface &&) noexcept=default
 

Detailed Description

Interface specifies all information for describing a JSON entity.

Schemas are instantiated through one of the many constructors that are defined.

Notes

Most constructor definitions make use of one of a set of private template constructors. These private template constructors enable slimmer constructors for all sorts of types later on. In order to differentiate between these constructors and the ones that users should use, the number of parameters and the order of types is sometimes varied.

We could use named constructors, but then you can not use the new operator with the construction or you need to use the copy constructor thereby constructing the schema twice.

Changes

When changing this Interface, the following implementors should be updated:

Box fable/schema/interface.hpp Schema fable/schema.hpp Variant fable/schema/variant.hpp FromConfable fable/schema/confable.hpp

Member Function Documentation

◆ clone()

◆ description()

◆ fail()

virtual std::optional<SchemaError> fable::schema::Interface::fail ( const Conf c) const
inlinefinalvirtual

Return input JSON configuration schema error, if any.

If you don't have a Conf but would like to validate a Json type, then construct a Conf on the fly:

s.fail(Conf{j});

This overload is not provided inline to prevent incorrect use.

Parameters
cJSON to check
Returns
error if invalid
Examples
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.24.0/fable/include/fable/schema/interface.hpp.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ from_conf()

◆ is_required()

◆ is_valid()

virtual bool fable::schema::Interface::is_valid ( const Conf c) const
inlinefinalvirtual

Return whether the input JSON is valid.

Examples
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.24.0/fable/include/fable/schema/interface.hpp.
Here is the call graph for this function:

◆ is_variant()

virtual bool fable::schema::Interface::is_variant ( ) const
inlinevirtual

Return whether the accepted input type is a variant.

A variant type is one that is composed of other types, such as the special types: any-of, one-of, and all-of.

Reimplemented in fable::schema::Variant, and fable::schema::Optional< T, P >.

Examples
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.24.0/fable/include/fable/schema/interface.hpp.

◆ json_schema()

◆ reset_ptr()

◆ set_description()

◆ to_json() [1/2]

virtual Json fable::schema::Interface::to_json ( ) const
inlinevirtual

◆ to_json() [2/2]

◆ type()

◆ type_string()

◆ usage()

virtual Json fable::schema::Interface::usage ( ) const
pure virtual

Return a compact JSON description of the schema. This is useful for human-readable error output.

Example output:

{ "field1": "boolean! :: lorem ipsum dolor sit amet", "field2": { "field2.1": "integer :: lorem ipsum dolor sit amet" "field2.2": "boolean :: lorem ipsum dolor sit amet" }, "field3": "array of integer :: lorem ipsum dolor sit amet", "field4": [{ "field4.1": "string :: lorem ipsum dolor sit amet" "field4.2": "boolean :: lorem ipsum dolor sit amet" }] }

When describing the schema of a primitive array, we can represent that as a single string. But when the array contains an object, we wrap a single object in an array. This isn't awfully consistent, but it's the best we can do.

Implemented in fable::schema::Variant, fable::schema::Struct, fable::schema::Base< CRTP >, fable::schema::Base< Array< T, N, P > >, fable::schema::Base< Path< T > >, fable::schema::Base< Factory< T > >, fable::schema::Base< FromConfable< T > >, fable::schema::Base< Vector< T, P > >, fable::schema::Base< String >, fable::schema::Base< FactoryPointerless< T > >, fable::schema::Base< VehicleSchema >, fable::schema::Base< Boolean >, fable::schema::Base< Optional< T, P > >, fable::schema::Base< FromJson< T > >, fable::schema::Base< Const< T, P > >, fable::schema::Base< Number< T > >, fable::schema::Base< Map< T, P > >, fable::schema::Base< Enum< T > >, fable::schema::Base< Duration< T, Period > >, fable::schema::Base< Ignore >, fable::schema::Base< Struct >, fable::schema::Base< Passthru< P > >, fable::schema::Box, fable::schema::CustomDeserializer, and fable::Schema.

Examples
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.24.0/fable/include/fable/schema/interface.hpp.

◆ validate()

virtual bool fable::schema::Interface::validate ( const Conf c,
std::optional< SchemaError > &  error 
) const
pure virtual

◆ validate_or_throw()

virtual void fable::schema::Interface::validate_or_throw ( const Conf c) const
inlinefinalvirtual

Validate the input JSON configuration or throw an error.

If you don't have a Conf but would like to validate a Json type, then construct a Conf on the fly:

s.validate_or_throw(Conf{j});

This overload is not provided inline to prevent incorrect use.

Parameters
cJSON to check
Examples
/home/docs/checkouts/readthedocs.org/user_builds/cloe/checkouts/v0.24.0/fable/include/fable/schema/interface.hpp.
Here is the call graph for this function:
Here is the caller graph for this function:

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