Expand description
Extension of vstr
module with convenience rules.
Logic
For conjunction and disjunction, the rules are always checked from the left and right, and short-circuiting is used.
The logical connectives may discard the error types of the rules they operate on in certain cases. These cases are documented in the respective types.
String size checking
StringSizeRule
checks a string’s length against an inclusive lower and upper bound.StringExactSizeRule
checks a string’s length against an exact size.StringMinSizeRule
checks a string’s length against an inclusive lower bound.StringMaxSizeRule
checks a string’s length against an inclusive upper bound.StringNonEmptyRule
checks a string’s length against an inclusive lower bound of 1.
StringSizeOutOfRangeError
is the error type for these rules.
NOTE: For dynamic bounds, please define your own rules.
Your rule just needs to implement ValidateString
.
The helpful macros easy_rule
and fast_rule
can help you with this task.
String content checking
StringAsciiRule
checks if a string is ASCII.
Structs
- Errors from both left and right, if only both places returned errors.
- Require both rules to pass, from left to right.
- Require either rule to pass, from left to right.
- Require the rule to NOT pass.
- The underlying rule passed.
- Require the string to not have any non-ASCII bytes.
- String had non-ASCII bytes.
- A rule that checks a string’s length against an inclusive upper bound.
- A rule that checks a string’s length against an inclusive lower bound.
- Out of range (bytes)
- A rule that checks the size of a string.
Enums
- An error from either left or right.
Type Definitions
- A rule that guarantees an exact length in bytes.
- A rule that says a string must not be empty.