pub struct PhoneE164Validator { /* private fields */ }Expand description
E.164 phone number validator.
Validates that a string is a valid E.164 international phone number:
a + followed by a non-zero country code digit and 6–14 more digits
(7–15 digits total after the +). No network I/O is performed.
§Example
use fraiseql_core::validation::async_validators::{AsyncValidator, PhoneE164Validator};
let v = PhoneE164Validator::new();
v.validate_async("+14155552671", "phone").await
.expect("E.164 number should pass phone validation");
assert!(
v.validate_async("0044207946000", "phone").await.is_err(),
"number without leading + should fail E.164 validation"
);
assert!(
v.validate_async("+123", "phone").await.is_err(),
"too-short number should fail phone validation"
);Implementations§
Trait Implementations§
Source§impl AsyncValidator for PhoneE164Validator
impl AsyncValidator for PhoneE164Validator
Source§fn validate_async<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
value: &'life1 str,
field: &'life2 str,
) -> Pin<Box<dyn Future<Output = AsyncValidatorResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn validate_async<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
value: &'life1 str,
field: &'life2 str,
) -> Pin<Box<dyn Future<Output = AsyncValidatorResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Validate a value asynchronously. Read more
Source§fn provider(&self) -> AsyncValidatorProvider
fn provider(&self) -> AsyncValidatorProvider
Get the provider this validator uses
Auto Trait Implementations§
impl Freeze for PhoneE164Validator
impl RefUnwindSafe for PhoneE164Validator
impl Send for PhoneE164Validator
impl Sync for PhoneE164Validator
impl Unpin for PhoneE164Validator
impl UnsafeUnpin for PhoneE164Validator
impl UnwindSafe for PhoneE164Validator
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more