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 ignore is specified.
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
}
}];
}Note that the required rule does not apply. Repeated items
cannot be unset.
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§fn clone_from(&mut self, source: &Self)
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
Source§impl ReflectMessage for RepeatedRules
impl ReflectMessage for RepeatedRules
Source§fn descriptor(&self) -> MessageDescriptor
fn descriptor(&self) -> MessageDescriptor
MessageDescriptor describing the type of this message.Source§fn transcode_to_dynamic(&self) -> DynamicMessagewhere
Self: Sized,
fn transcode_to_dynamic(&self) -> DynamicMessagewhere
Self: Sized,
DynamicMessage by going
through the byte representation.