pub enum StringValidator {
Show 69 variants
String,
Alpha,
Alphanumeric,
Base64,
Base64Url,
Capitalize,
CapitalizePreformatted,
CreditCard,
Date,
DateEpoch,
DateEpochParse,
DateIso,
DateIsoParse,
DateParse,
Digits,
Email,
Hex,
Integer,
IntegerParse,
Ip,
IpV4,
IpV6,
Json,
JsonParse,
Lower,
LowerPreformatted,
Normalize,
NormalizeNFC,
NormalizeNFCPreformatted,
NormalizeNFD,
NormalizeNFDPreformatted,
NormalizeNFKC,
NormalizeNFKCPreformatted,
NormalizeNFKD,
NormalizeNFKDPreformatted,
Numeric,
NumericParse,
Regex,
Semver,
Trim,
TrimPreformatted,
Upper,
UpperPreformatted,
Url,
UrlParse,
Uuid,
UuidV1,
UuidV2,
UuidV3,
UuidV4,
UuidV5,
UuidV6,
UuidV7,
UuidV8,
Literal(String),
StringEmbedded(String),
RegexLiteral(Format),
Length(String),
MinLength(usize),
MaxLength(usize),
NonEmpty,
StartsWith(String),
EndsWith(String),
Includes(String),
Trimmed,
Lowercased,
Uppercased,
Capitalized,
Uncapitalized,
}Expand description
Describes various string validation and transformation _requirements.
Variants§
String
A string
Alpha
Only letters
Alphanumeric
Only letters and digits 0-9
Base64
Base64-encoded
Base64Url
Base64url-encoded
Capitalize
A morph from a string to capitalized
CapitalizePreformatted
Capitalized
CreditCard
A credit card number and a credit card number
Date
A string and a parsable date
DateEpoch
An integer string representing a safe Unix timestamp
DateEpochParse
A morph from an integer string representing a safe Unix timestamp to a Date
DateIso
An ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date
DateIsoParse
A morph from an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date to a Date
DateParse
A morph from a string and a parsable date to a Date
Digits
Only digits 0-9
An email address
Hex
Hex characters only
Integer
A well-formed integer string
IntegerParse
A morph from a well-formed integer string to an integer
Ip
An IP address
IpV4
An IPv4 address
IpV6
An IPv6 address
Json
A JSON string
JsonParse
Safe JSON string parser
Lower
A morph from a string to only lowercase letters
LowerPreformatted
Only lowercase letters
Normalize
A morph from a string to NFC-normalized unicode
NormalizeNFC
A morph from a string to NFC-normalized unicode
NormalizeNFCPreformatted
NFC-normalized unicode
NormalizeNFD
A morph from a string to NFD-normalized unicode
NormalizeNFDPreformatted
NFD-normalized unicode
NormalizeNFKC
A morph from a string to NFKC-normalized unicode
NormalizeNFKCPreformatted
NFKC-normalized unicode
NormalizeNFKD
A morph from a string to NFKD-normalized unicode
NormalizeNFKDPreformatted
NFKD-normalized unicode
Numeric
A well-formed numeric string
NumericParse
A morph from a well-formed numeric string to a number
Regex
A string and a regex pattern
Semver
A semantic version (see https://semver.org/)
Trim
A morph from a string to trimmed
TrimPreformatted
Trimmed
Upper
A morph from a string to only uppercase letters
UpperPreformatted
Only uppercase letters
Url
A string and a URL string
UrlParse
A morph from a string and a URL string to a URL instance
Uuid
A UUID
UuidV1
A UUIDv1
UuidV2
A UUIDv2
UuidV3
A UUIDv3
UuidV4
A UUIDv4
UuidV5
A UUIDv5
UuidV6
A UUIDv6
UuidV7
A UUIDv7
UuidV8
A UUIDv8
Literal(String)
StringEmbedded(String)
RegexLiteral(Format)
Length(String)
MinLength(usize)
Minimum length of a string
MaxLength(usize)
Maximum length of a string
NonEmpty
Non-empty string (equivalent to MinLength(1))
StartsWith(String)
String starts with a specific prefix
EndsWith(String)
String ends with a specific suffix
Includes(String)
String includes a specific substring
Trimmed
String has no leading or trailing whitespace (validation only)
Lowercased
String is entirely lowercase (validation only)
Uppercased
String is entirely uppercase (validation only)
Capitalized
String is capitalized (validation only)
Uncapitalized
String is uncapitalized (validation only)
Implementations§
Source§impl StringValidator
impl StringValidator
pub fn unwrap_expr(expr: &Expr) -> &Expr
pub fn determine_enum_type(expr: &Expr) -> Result<String, Error>
pub fn parse_string_literal(expr: &Expr) -> Result<String, Error>
pub fn parse_bool_literal(expr: &Expr) -> Result<bool, Error>
pub fn parse_char_literal(expr: &Expr) -> Result<char, Error>
pub fn parse_i8_literal(expr: &Expr) -> Result<i8, Error>
pub fn parse_i16_literal(expr: &Expr) -> Result<i16, Error>
pub fn parse_i32_literal(expr: &Expr) -> Result<i32, Error>
pub fn parse_i64_literal(expr: &Expr) -> Result<i64, Error>
pub fn parse_isize_literal(expr: &Expr) -> Result<isize, Error>
pub fn parse_u8_literal(expr: &Expr) -> Result<u8, Error>
pub fn parse_u16_literal(expr: &Expr) -> Result<u16, Error>
pub fn parse_u32_literal(expr: &Expr) -> Result<u32, Error>
pub fn parse_u64_literal(expr: &Expr) -> Result<u64, Error>
pub fn parse_usize_literal(expr: &Expr) -> Result<usize, Error>
pub fn parse_f32_literal(expr: &Expr) -> Result<f32, Error>
pub fn parse_f64_literal(expr: &Expr) -> Result<f64, Error>
pub fn parse_from_expr(expr: &Expr) -> Result<StringValidator, Error>
Trait Implementations§
Source§impl Clone for StringValidator
impl Clone for StringValidator
Source§fn clone(&self) -> StringValidator
fn clone(&self) -> StringValidator
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StringValidator
impl Debug for StringValidator
Source§impl<'de> Deserialize<'de> for StringValidator
impl<'de> Deserialize<'de> for StringValidator
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<StringValidator, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<StringValidator, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<StringValidator> for Validator
impl From<StringValidator> for Validator
Source§fn from(value: StringValidator) -> Validator
fn from(value: StringValidator) -> Validator
Source§impl Hash for StringValidator
impl Hash for StringValidator
Source§impl PartialEq for StringValidator
impl PartialEq for StringValidator
Source§impl Serialize for StringValidator
impl Serialize for StringValidator
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl ToTokens for StringValidator
impl ToTokens for StringValidator
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
Source§impl TryFrom<&Expr> for StringValidator
impl TryFrom<&Expr> for StringValidator
impl Eq for StringValidator
impl StructuralPartialEq for StringValidator
Auto Trait Implementations§
impl Freeze for StringValidator
impl RefUnwindSafe for StringValidator
impl Send for StringValidator
impl Sync for StringValidator
impl Unpin for StringValidator
impl UnsafeUnpin for StringValidator
impl UnwindSafe for StringValidator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> ImplicitClone for Twhere
T: Clone,
impl<T> ImplicitClone for Twhere
T: Clone,
fn clone_quote_var(&self) -> Self
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere
T: Spanned + ?Sized,
Source§fn span(&self) -> Span
fn span(&self) -> Span
Span covering the complete contents of this syntax tree
node, or Span::call_site() if this node is empty.