pub struct ConstraintSet { /* private fields */ }Expand description
A set of field constraints for a message type.
Typically one ConstraintSet is constructed per message schema (e.g. pacs.008)
and reused across many validations.
§Examples
use mx20022_validate::schema::constraints::{ConstraintSet, FieldConstraint};
use mx20022_validate::rules::RuleRegistry;
let mut cs = ConstraintSet::new();
cs.add(FieldConstraint::new(
"/Document/GrpHdr/MsgId",
["MAX_LENGTH"],
));Implementations§
Source§impl ConstraintSet
impl ConstraintSet
Sourcepub fn add(&mut self, constraint: FieldConstraint)
pub fn add(&mut self, constraint: FieldConstraint)
Add a constraint to the set.
Sourcepub fn for_path(&self, path: &str) -> Vec<&FieldConstraint>
pub fn for_path(&self, path: &str) -> Vec<&FieldConstraint>
Look up all constraints for a given path.
Sourcepub fn validate_field(
&self,
path: &str,
value: &str,
registry: &RuleRegistry,
) -> ValidationResult
pub fn validate_field( &self, path: &str, value: &str, registry: &RuleRegistry, ) -> ValidationResult
Validate a (path, value) pair against all matching constraints using registry.
Returns a ValidationResult aggregating any findings.
Trait Implementations§
Source§impl Debug for ConstraintSet
impl Debug for ConstraintSet
Source§impl Default for ConstraintSet
impl Default for ConstraintSet
Source§fn default() -> ConstraintSet
fn default() -> ConstraintSet
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ConstraintSet
impl RefUnwindSafe for ConstraintSet
impl Send for ConstraintSet
impl Sync for ConstraintSet
impl Unpin for ConstraintSet
impl UnsafeUnpin for ConstraintSet
impl UnwindSafe for ConstraintSet
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