pub struct RepeatedRules {
pub min_items: Option<u64>,
pub max_items: Option<u64>,
pub unique: Option<bool>,
pub items: Option<Box<FieldRules>>,
}
Expand description
RepeatedRules describe the rules applied to repeated
values.
Fields§
§min_items: Option<u64>
min_items
requires that this field must contain at least the specified
minimum number of items.
Note that min_items = 1
is equivalent to setting a field as required
.
message MyRepeated {
// value must contain at least 2 items
repeated string value = 1 \[(buf.validate.field).repeated.min_items = 2\];
}
max_items: Option<u64>
max_items
denotes that this field must not exceed a
certain number of items as the upper limit. If the field contains more
items than specified, an error message will be generated, requiring the
field to maintain no more than the specified number of items.
message MyRepeated {
// value must contain no more than 3 item(s)
repeated string value = 1 \[(buf.validate.field).repeated.max_items = 3\];
}
unique: Option<bool>
unique
indicates that all elements in this field must
be unique. This rule is strictly applicable to scalar and enum
types, with message types not being supported.
message MyRepeated {
// repeated value must contain unique items
repeated string value = 1 \[(buf.validate.field).repeated.unique = true\];
}
items: Option<Box<FieldRules>>
items
details the rules to be applied to each item
in the field. Even for repeated message fields, validation is executed
against each item unless skip is explicitly specified.
Note that repeated items are always considered populated. The required
rule does not apply.
message MyRepeated {
// The items in the field `value` must follow the specified rules.
repeated string value = 1 [(buf.validate.field).repeated.items = {
string: {
min_len: 3
max_len: 10
}
}];
}
Implementations§
Trait Implementations§
Source§impl Clone for RepeatedRules
impl Clone for RepeatedRules
Source§fn clone(&self) -> RepeatedRules
fn clone(&self) -> RepeatedRules
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for RepeatedRules
impl Debug for RepeatedRules
Source§impl Default for RepeatedRules
impl Default for RepeatedRules
Source§impl Message for RepeatedRules
impl Message for RepeatedRules
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self
.Source§impl PartialEq for RepeatedRules
impl PartialEq for RepeatedRules
impl StructuralPartialEq for RepeatedRules
Auto Trait Implementations§
impl Freeze for RepeatedRules
impl RefUnwindSafe for RepeatedRules
impl Send for RepeatedRules
impl Sync for RepeatedRules
impl Unpin for RepeatedRules
impl UnwindSafe for RepeatedRules
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<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::Request