cli20 0.1.2
A C++20 typed-schema command-line parser
Loading...
Searching...
No Matches
cli::validation Namespace Reference

Actions that validate a typed value after conversion. More...

Classes

struct  Min
 Validates that the input value is greater than or equal to MinValue. More...
struct  Max
 Validates that the input value is less than or equal to MaxValue. More...
struct  Range
 Validates that the input value is within the closed interval [MinValue, MaxValue]. More...
struct  Positive
 Validates that the input value is strictly positive (> 0). More...
struct  NonNegative
 Validates that the input value is non-negative (>= 0). More...
struct  NonEmpty
 Validates that the input value is not empty (requires .empty() member). More...
struct  NotBlank
 Validates that the input string is not blank (not all whitespace). More...
struct  OneOf
 Validates that the input value equals one of the compile-time constants Allowed. More...
struct  Matches
 Validates that the input string matches a compile-time regular expression. More...
struct  Exists
 Validates that a std::filesystem::path exists on the filesystem. More...
struct  IsRegularFile
 Validates that a std::filesystem::path refers to a regular file. More...
struct  IsDirectory
 Validates that a std::filesystem::path refers to a directory. More...
struct  ParentExists
 Validates that the parent directory of a std::filesystem::path exists. More...
struct  Predicate
 Validates a value using a user-supplied compile-time predicate. More...

Variables

template<auto MinValue>
constexpr auto min = Action<Min<MinValue>{}>{}
template<auto MaxValue>
constexpr auto max = Action<Max<MaxValue>{}>{}
template<auto MinValue, auto MaxValue>
constexpr auto range = Action<Range<MinValue, MaxValue>{}>{}
template<auto... Allowed>
constexpr auto one_of = Action<OneOf<Allowed...>{}>{}
template<StringLiteral Pattern>
constexpr auto matches = Action<Matches<Pattern>{}>{}
template<auto Pred>
constexpr auto predicate = Action<Predicate<Pred>{}>{}
constexpr auto positive = Action<Positive{}>{}
constexpr auto non_negative = Action<NonNegative{}>{}
constexpr auto non_empty = Action<NonEmpty{}>{}
constexpr auto not_blank = Action<NotBlank{}>{}
constexpr auto exists = Action<Exists{}>{}
constexpr auto is_regular_file = Action<IsRegularFile{}>{}
constexpr auto is_directory = Action<IsDirectory{}>{}
constexpr auto parent_exists = Action<ParentExists{}>{}

Detailed Description

Actions that validate a typed value after conversion.

Each action in this namespace passes its input through unchanged on success or returns ErrorCode::validation_failed / ErrorCode::invalid_choice on failure. They are placed after a conversion action and before a pack action:

constexpr auto my_action = cli::conversion::integer<int>
constexpr auto integer
Definition action.hh:921
constexpr auto set_once
Definition action.hh:1877
constexpr auto range
Definition action.hh:1450

Variable Documentation

◆ exists

auto cli::validation::exists = Action<Exists{}>{}
inlineconstexpr

Definition at line 1461 of file action.hh.

◆ is_directory

auto cli::validation::is_directory = Action<IsDirectory{}>{}
inlineconstexpr

Definition at line 1463 of file action.hh.

◆ is_regular_file

auto cli::validation::is_regular_file = Action<IsRegularFile{}>{}
inlineconstexpr

Definition at line 1462 of file action.hh.

◆ matches

template<StringLiteral Pattern>
auto cli::validation::matches = Action<Matches<Pattern>{}>{}
inlineconstexpr

Definition at line 1454 of file action.hh.

◆ max

template<auto MaxValue>
auto cli::validation::max = Action<Max<MaxValue>{}>{}
inlineconstexpr

Definition at line 1448 of file action.hh.

◆ min

template<auto MinValue>
auto cli::validation::min = Action<Min<MinValue>{}>{}
inlineconstexpr

Definition at line 1446 of file action.hh.

◆ non_empty

auto cli::validation::non_empty = Action<NonEmpty{}>{}
inlineconstexpr

Definition at line 1459 of file action.hh.

◆ non_negative

auto cli::validation::non_negative = Action<NonNegative{}>{}
inlineconstexpr

Definition at line 1458 of file action.hh.

◆ not_blank

auto cli::validation::not_blank = Action<NotBlank{}>{}
inlineconstexpr

Definition at line 1460 of file action.hh.

◆ one_of

template<auto... Allowed>
auto cli::validation::one_of = Action<OneOf<Allowed...>{}>{}
inlineconstexpr

Definition at line 1452 of file action.hh.

◆ parent_exists

auto cli::validation::parent_exists = Action<ParentExists{}>{}
inlineconstexpr

Definition at line 1464 of file action.hh.

◆ positive

auto cli::validation::positive = Action<Positive{}>{}
inlineconstexpr

Definition at line 1457 of file action.hh.

◆ predicate

template<auto Pred>
auto cli::validation::predicate = Action<Predicate<Pred>{}>{}
inlineconstexpr

Definition at line 1456 of file action.hh.

◆ range

template<auto MinValue, auto MaxValue>
auto cli::validation::range = Action<Range<MinValue, MaxValue>{}>{}
inlineconstexpr

Definition at line 1450 of file action.hh.