pub struct PasswordRule { /* private fields */ }Expand description
What a new password must contain, such as at least 8 characters with a number.
The password validation rule checks a field against the application’s defaults. Register a
PasswordRule in your services to choose them. Without one, a password needs at least 8
characters:
use laravel::Application;
use laravel::validation::PasswordRule;
let app = Application::configure()
.with_services(|app| {
app.instance(PasswordRule::min(8).letters().mixed_case().numbers());
});A password that misses several requirements gets a message for each one, as in Laravel Classic.
To use other requirements for one field, pass them to the rule, as in
#[validate(password(min = 12, symbols))], or convert a PasswordRule into a
Rule with Rule::from.
Implementations§
Source§impl PasswordRule
impl PasswordRule
Sourcepub const fn min(min: usize) -> PasswordRule
pub const fn min(min: usize) -> PasswordRule
Requires at least min characters, and at least one.
Sourcepub const fn max(self, max: usize) -> PasswordRule
pub const fn max(self, max: usize) -> PasswordRule
Allows at most max characters.
Sourcepub const fn letters(self) -> PasswordRule
pub const fn letters(self) -> PasswordRule
Requires at least one letter.
Sourcepub const fn mixed_case(self) -> PasswordRule
pub const fn mixed_case(self) -> PasswordRule
Requires at least one uppercase and one lowercase letter.
Sourcepub const fn numbers(self) -> PasswordRule
pub const fn numbers(self) -> PasswordRule
Requires at least one number.
Sourcepub const fn symbols(self) -> PasswordRule
pub const fn symbols(self) -> PasswordRule
Requires at least one symbol, such as punctuation or a space.
Trait Implementations§
Source§impl Clone for PasswordRule
impl Clone for PasswordRule
Source§fn clone(&self) -> PasswordRule
fn clone(&self) -> PasswordRule
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PasswordRule
Source§impl Debug for PasswordRule
impl Debug for PasswordRule
Source§impl Default for PasswordRule
At least 8 characters, Laravel Classic’s default.
impl Default for PasswordRule
At least 8 characters, Laravel Classic’s default.
Source§fn default() -> PasswordRule
fn default() -> PasswordRule
impl Eq for PasswordRule
Source§impl From<PasswordRule> for Rule
Converts password requirements into a rule for one field, in place of the application’s
defaults that Rule::password checks.
impl From<PasswordRule> for Rule
Converts password requirements into a rule for one field, in place of the application’s
defaults that Rule::password checks.
use laravel::validation::{PasswordRule, Rule, Rules};
let rules = Rules::new().field("password", [Rule::required(), Rule::from(PasswordRule::min(12).symbols())]);Source§fn from(rule: PasswordRule) -> Rule
fn from(rule: PasswordRule) -> Rule
Source§impl PartialEq for PasswordRule
impl PartialEq for PasswordRule
impl StructuralPartialEq for PasswordRule
Auto Trait Implementations§
impl Forget for PasswordRule
impl Freeze for PasswordRule
impl Move for PasswordRule
impl RefUnwindSafe for PasswordRule
impl Send for PasswordRule
impl Sync for PasswordRule
impl Unpin for PasswordRule
impl UnsafeUnpin for PasswordRule
impl UnwindSafe for PasswordRule
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<K> ForeignKey<K> for K
impl<K> ForeignKey<K> for K
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<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 more