# Struct type_validator

- Defined in File validate.hpp

## Struct Documentation

struct type_validator

  For each defined type in a dictionary a type_validator is created.

  A type validator can check if the contents of an item are conforming the specification. The check is done using regular expressions.

  A type_validator can also be used to compare two values that conform to this type. Comparison is of course based on the primitive type.

  Public Functions

  type_validator() = delete
  type_validator(std::string_view name, DDL_PrimitiveType type, std::string_view rx)

    Constructor.

  type_validator(const type_validator &tv) = default

    Copy constructor.

  inline type_validator(type_validator &&rhs)

    Move constructor.

  inline type_validator &operator=(type_validator rhs)

    Move constructor.

  ~type_validator() = default

    Destructor.

  inline bool operator<(const type_validator &rhs) const

    Return the sorting order.

  int compare(const item_value &a, const item_value &b) const

    Compare the contents of a and b based on the primitive type of this type. A value of zero indicates the values are equal. Less than zero means a sorts before b and a value larger than zero likewise means the opposite.

  Public Members

  std::string m_name

    The name of the type.

  DDL_PrimitiveType m_primitive_type

    The primitive_type of the type.

  std::shared_ptr<regex_impl> m_rx

    The regular expression for the type.

  Friends

  inline friend void swap(type_validator &a, type_validator &b)

    Swap two type validators.