pub struct FieldSchema {
pub name: String,
pub rules: Vec<ValidationRule>,
pub default: Option<String>,
pub description: String,
}Expand description
字段校验定义
Fields§
§name: String字段名
rules: Vec<ValidationRule>校验规则列表(全部必须通过)
default: Option<String>默认值(可选)
description: String描述
Implementations§
Source§impl FieldSchema
impl FieldSchema
Sourcepub fn with_rule(self, rule: ValidationRule) -> Self
pub fn with_rule(self, rule: ValidationRule) -> Self
添加规则(链式)
Sourcepub fn with_default(self, value: &str) -> Self
pub fn with_default(self, value: &str) -> Self
设置默认值(链式)
Sourcepub fn with_description(self, desc: &str) -> Self
pub fn with_description(self, desc: &str) -> Self
设置描述(链式)
Sourcepub fn validate(&self, value: Option<&str>) -> ValidationResult
pub fn validate(&self, value: Option<&str>) -> ValidationResult
校验单个值
Trait Implementations§
Source§impl Clone for FieldSchema
impl Clone for FieldSchema
Source§fn clone(&self) -> FieldSchema
fn clone(&self) -> FieldSchema
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FieldSchema
impl RefUnwindSafe for FieldSchema
impl Send for FieldSchema
impl Sync for FieldSchema
impl Unpin for FieldSchema
impl UnsafeUnpin for FieldSchema
impl UnwindSafe for FieldSchema
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