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
StringSizeRulechecks a string’s length against an inclusive lower and upper bound.StringExactSizeRulechecks a string’s length against an exact size.StringMinSizeRulechecks a string’s length against an inclusive lower bound.StringMaxSizeRulechecks a string’s length against an inclusive upper bound.StringNonEmptyRulechecks a string’s length against an inclusive lower bound of 1.
StringSizeOutOfRangeErroris 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
StringAsciiRulechecks if a string is ASCII.
Structs§
- Both
Error - Errors from both left and right, if only both places returned errors.
- Conj
- Require both rules to pass, from left to right.
- Disj
- Require either rule to pass, from left to right.
- Neg
- Require the rule to NOT pass.
- Negation
Passed Error - The underlying rule passed.
- String
Ascii Rule - Require the string to not have any non-ASCII bytes.
- String
HadNon Ascii Error - String had non-ASCII bytes.
- String
MaxSize Rule - A rule that checks a string’s length against an inclusive upper bound.
- String
MinSize Rule - A rule that checks a string’s length against an inclusive lower bound.
- String
Size OutOf Range Error - Out of range (bytes)
- String
Size Rule - A rule that checks the size of a string.
Enums§
- Either
Error - An error from either left or right.
Type Aliases§
- String
Exact Size Rule - A rule that guarantees an exact length in bytes.
- String
NonEmpty Rule - A rule that says a string must not be empty.