pub struct MapValidatorBuilder<K, V, S: State = Empty>where
K: ProtoValidation,
V: ProtoValidation,{ /* private fields */ }Expand description
Builder for MapValidator.
Implementations§
Source§impl<S: State, K, V> MapValidatorBuilder<K, V, S>where
K: ProtoValidation,
V: ProtoValidation,
impl<S: State, K, V> MapValidatorBuilder<K, V, S>where
K: ProtoValidation,
V: ProtoValidation,
Sourcepub fn build(self) -> MapValidator<K, V>
pub fn build(self) -> MapValidator<K, V>
Builds the validator.
If the values validator is unset, but the target has HAS_DEFAULT_VALIDATOR from ProtoValidation set to true,
its default validator will be assigned.
Sourcepub fn with_error_messages(
self,
error_messages: impl IntoIterator<Item = (MapViolation, impl Into<FixedStr>)>,
) -> MapValidatorBuilder<K, V, SetErrorMessages<S>>where
S::ErrorMessages: IsUnset,
pub fn with_error_messages(
self,
error_messages: impl IntoIterator<Item = (MapViolation, impl Into<FixedStr>)>,
) -> MapValidatorBuilder<K, V, SetErrorMessages<S>>where
S::ErrorMessages: IsUnset,
Adds a map with custom error messages to the underlying validator.
If a violation has no custom error message attached to it, it uses the default error message.
NOTE: The custom errors for items and keys must be handled in their respective validators.
Sourcepub fn cel(self, program: CelProgram) -> Self
pub fn cel(self, program: CelProgram) -> Self
Adds a CelProgram to this validator.
The program will be applied to the map as a whole.
To apply a program to the individual keys/values, use their respective validators.
Sourcepub fn min_pairs(self, num: usize) -> MapValidatorBuilder<K, V, SetMinPairs<S>>where
S::MinPairs: IsUnset,
pub fn min_pairs(self, num: usize) -> MapValidatorBuilder<K, V, SetMinPairs<S>>where
S::MinPairs: IsUnset,
Specifies the minimum amount of key-value pairs that this field should have in order to be valid.
Sourcepub fn max_pairs(self, num: usize) -> MapValidatorBuilder<K, V, SetMaxPairs<S>>where
S::MaxPairs: IsUnset,
pub fn max_pairs(self, num: usize) -> MapValidatorBuilder<K, V, SetMaxPairs<S>>where
S::MaxPairs: IsUnset,
Specifies the maximum amount of key-value pairs that this field should have in order to be valid.
Sourcepub fn ignore_if_zero_value(self) -> MapValidatorBuilder<K, V, SetIgnore<S>>where
S::Ignore: IsUnset,
pub fn ignore_if_zero_value(self) -> MapValidatorBuilder<K, V, SetIgnore<S>>where
S::Ignore: IsUnset,
Specifies that this validator’s rules will be ignored if the map is empty.
Sourcepub fn ignore_always(self) -> MapValidatorBuilder<K, V, SetIgnore<S>>where
S::Ignore: IsUnset,
pub fn ignore_always(self) -> MapValidatorBuilder<K, V, SetIgnore<S>>where
S::Ignore: IsUnset,
Specifies that this validator should always be ignored.
Sourcepub fn keys<F, FinalBuilder>(
self,
config_fn: F,
) -> MapValidatorBuilder<K, V, SetKeys<S>>where
S::Keys: IsUnset,
FinalBuilder: ValidatorBuilderFor<K, Validator = K::Validator>,
F: FnOnce(K::ValidatorBuilder) -> FinalBuilder,
pub fn keys<F, FinalBuilder>(
self,
config_fn: F,
) -> MapValidatorBuilder<K, V, SetKeys<S>>where
S::Keys: IsUnset,
FinalBuilder: ValidatorBuilderFor<K, Validator = K::Validator>,
F: FnOnce(K::ValidatorBuilder) -> FinalBuilder,
Sets the rules to apply to each key of this map.
It receives a closure that that receives the key type’s default validator builder as an argument.
§Example
use protify::*;
let validator = MapValidator::<String, String>::builder().keys(|k| k.min_len(5)).build();
assert_eq!(validator.keys.unwrap(), StringValidator::builder().min_len(5).build());Sourcepub fn values<F, FinalBuilder>(
self,
config_fn: F,
) -> MapValidatorBuilder<K, V, SetValues<S>>where
V: ProtoValidation,
FinalBuilder: ValidatorBuilderFor<V, Validator = V::Validator>,
F: FnOnce(V::ValidatorBuilder) -> FinalBuilder,
pub fn values<F, FinalBuilder>(
self,
config_fn: F,
) -> MapValidatorBuilder<K, V, SetValues<S>>where
V: ProtoValidation,
FinalBuilder: ValidatorBuilderFor<V, Validator = V::Validator>,
F: FnOnce(V::ValidatorBuilder) -> FinalBuilder,
Sets the rules to apply to each value of this map.
It receives a closure that that receives the value type’s default validator builder as an argument.
§Example
use protify::*;
let validator = MapValidator::<String, String>::builder().values(|v| v.min_len(5)).build();
assert_eq!(validator.values.unwrap(), StringValidator::builder().min_len(5).build());Trait Implementations§
Source§impl<K, V, S: Clone + State> Clone for MapValidatorBuilder<K, V, S>where
K: ProtoValidation + Clone,
V: ProtoValidation + Clone,
K::Validator: Clone,
V::Validator: Clone,
impl<K, V, S: Clone + State> Clone for MapValidatorBuilder<K, V, S>where
K: ProtoValidation + Clone,
V: ProtoValidation + Clone,
K::Validator: Clone,
V::Validator: Clone,
Source§fn clone(&self) -> MapValidatorBuilder<K, V, S>
fn clone(&self) -> MapValidatorBuilder<K, V, S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<K, V, S: Debug + State> Debug for MapValidatorBuilder<K, V, S>where
K: ProtoValidation + Debug,
V: ProtoValidation + Debug,
K::Validator: Debug,
V::Validator: Debug,
impl<K, V, S: Debug + State> Debug for MapValidatorBuilder<K, V, S>where
K: ProtoValidation + Debug,
V: ProtoValidation + Debug,
K::Validator: Debug,
V::Validator: Debug,
Source§impl<K, V, S: State> Default for MapValidatorBuilder<K, V, S>where
K: ProtoValidation,
V: ProtoValidation,
impl<K, V, S: State> Default for MapValidatorBuilder<K, V, S>where
K: ProtoValidation,
V: ProtoValidation,
Source§impl<K, V, S: State> From<MapValidatorBuilder<K, V, S>> for ProtoOptionwhere
K: ProtoValidation,
V: ProtoValidation,
impl<K, V, S: State> From<MapValidatorBuilder<K, V, S>> for ProtoOptionwhere
K: ProtoValidation,
V: ProtoValidation,
Source§fn from(value: MapValidatorBuilder<K, V, S>) -> Self
fn from(value: MapValidatorBuilder<K, V, S>) -> Self
Source§impl<K, V, S: Hash + State> Hash for MapValidatorBuilder<K, V, S>
impl<K, V, S: Hash + State> Hash for MapValidatorBuilder<K, V, S>
Source§impl<K, V, S: PartialEq + State> PartialEq for MapValidatorBuilder<K, V, S>where
K: ProtoValidation + PartialEq,
V: ProtoValidation + PartialEq,
K::Validator: PartialEq,
V::Validator: PartialEq,
impl<K, V, S: PartialEq + State> PartialEq for MapValidatorBuilder<K, V, S>where
K: ProtoValidation + PartialEq,
V: ProtoValidation + PartialEq,
K::Validator: PartialEq,
V::Validator: PartialEq,
Source§fn eq(&self, other: &MapValidatorBuilder<K, V, S>) -> bool
fn eq(&self, other: &MapValidatorBuilder<K, V, S>) -> bool
self and other values to be equal, and is used by ==.Source§impl<K, V, M, S> ValidatorBuilderFor<M> for MapValidatorBuilder<K, V, S>
impl<K, V, M, S> ValidatorBuilderFor<M> for MapValidatorBuilder<K, V, S>
type Validator = MapValidator<K, V>
Source§fn build_validator(self) -> Self::Validator
fn build_validator(self) -> Self::Validator
Validator.impl<K, V, S: Eq + State> Eq for MapValidatorBuilder<K, V, S>
impl<K, V, S: State> StructuralPartialEq for MapValidatorBuilder<K, V, S>where
K: ProtoValidation,
V: ProtoValidation,
Auto Trait Implementations§
impl<K, V, S> Freeze for MapValidatorBuilder<K, V, S>
impl<K, V, S> RefUnwindSafe for MapValidatorBuilder<K, V, S>where
<K as ProtoValidation>::Validator: RefUnwindSafe,
S: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
<V as ProtoValidation>::Validator: RefUnwindSafe,
impl<K, V, S> Send for MapValidatorBuilder<K, V, S>
impl<K, V, S> Sync for MapValidatorBuilder<K, V, S>
impl<K, V, S> Unpin for MapValidatorBuilder<K, V, S>where
<K as ProtoValidation>::Validator: Unpin,
S: Unpin,
K: Unpin,
V: Unpin,
<V as ProtoValidation>::Validator: Unpin,
impl<K, V, S> UnwindSafe for MapValidatorBuilder<K, V, S>where
<K as ProtoValidation>::Validator: UnwindSafe,
S: UnwindSafe,
K: UnwindSafe,
V: UnwindSafe,
<V as ProtoValidation>::Validator: UnwindSafe,
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointerSource§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<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
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<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> 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<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more