NDEVR
API Documentation
StringValidator

Logic for validating a string given a specific regex pattern. More...

Static Public Member Functions

static bool checkRegex (const StringView &string, const StringView &regex, uint04 start_index=0, uint04 end_index=Constant< uint04 >::Invalid, uint04 max_size=256)
 Checks whether a substring of the given string matches the specified regex pattern.
template<class t_type>
static bool isValid (const StringView &string)
 Checks whether the given string is valid for the specified type using its associated regex.
static bool isValid (const StringView &string, const TypeInfo &type)
 Checks whether the given string is valid for the specified TypeInfo using its associated regex.
template<class t_type>
static const char * regex ()
 Retrieves the validation regex pattern string for the specified type.
static const char * regex (const TypeInfo &type)
 Retrieves the validation regex pattern string for the specified TypeInfo.

Detailed Description

Logic for validating a string given a specific regex pattern.


Provides static utility methods to check whether a string matches a regular expression, with support for both compile-time type-based and runtime TypeInfo-based validation.

Definition at line 46 of file StringValidator.h.

Member Function Documentation

◆ checkRegex()

bool StringValidator::checkRegex ( const StringView & string,
const StringView & regex,
uint04 start_index = 0,
uint04 end_index = Constantuint04 >::Invalid,
uint04 max_size = 256 )
static

Checks whether a substring of the given string matches the specified regex pattern.

Parameters
[in]stringThe string to validate.
[in]regexThe regex pattern to match against.
[in]start_indexThe starting character index within the string.
[in]end_indexThe ending character index within the string. Invalid means the full remaining length.
[in]max_sizeThe maximum allowed size of the string for validation.
Returns
True if the substring matches the regex pattern, false otherwise.

References regex().

◆ isValid() [1/2]

template<class t_type>
bool StringValidator::isValid ( const StringView & string)
inlinestatic

Checks whether the given string is valid for the specified type using its associated regex.

Parameters
[in]stringThe string to validate.
Returns
True if the string matches the regex for the given type, false otherwise.

Definition at line 66 of file StringValidator.h.

References regex().

◆ isValid() [2/2]

bool StringValidator::isValid ( const StringView & string,
const TypeInfo & type )
inlinestatic

Checks whether the given string is valid for the specified TypeInfo using its associated regex.

Parameters
[in]stringThe string to validate.
[in]typeThe TypeInfo describing the expected format.
Returns
True if the string matches the regex for the given type, false otherwise.

Definition at line 77 of file StringValidator.h.

References regex(), and type.

◆ regex() [1/2]

template<class t_type>
const char * StringValidator::regex ( )
inlinestatic

Retrieves the validation regex pattern string for the specified type.

Returns
A C-string containing the regex pattern for the given type.

Definition at line 87 of file StringValidator.h.

References StringStream< t_type >::getValidRegex().

Referenced by checkRegex(), isValid(), and isValid().

◆ regex() [2/2]

const char * StringValidator::regex ( const TypeInfo & type)
static

Retrieves the validation regex pattern string for the specified TypeInfo.

Parameters
[in]typeThe TypeInfo describing the expected format.
Returns
A C-string containing the regex pattern for the given type.

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