pub struct ValidationContext { /* private fields */ }Expand description
Context for validation operations.
Provides runtime state during validation, including:
- Field values for cross-field validation
- Metadata storage
- Locale settings for i18n
§Example
use skp_validator_core::ValidationContext;
let ctx = ValidationContext::new()
.with_locale("en")
.with_meta("request_id", "123");Implementations§
Source§impl ValidationContext
impl ValidationContext
Sourcepub fn with_locale(self, locale: impl Into<String>) -> Self
pub fn with_locale(self, locale: impl Into<String>) -> Self
Set the locale for error messages
Sourcepub fn with_fail_fast(self, fail_fast: bool) -> Self
pub fn with_fail_fast(self, fail_fast: bool) -> Self
Set fail-fast mode (stop on first error)
Sourcepub fn with_custom_data<T: Any + Send + Sync>(self, data: T) -> Self
pub fn with_custom_data<T: Any + Send + Sync>(self, data: T) -> Self
Set custom data (type-erased)
Sourcepub fn is_fail_fast(&self) -> bool
pub fn is_fail_fast(&self) -> bool
Check if fail-fast mode is enabled
Sourcepub fn field_names(&self) -> impl Iterator<Item = &String>
pub fn field_names(&self) -> impl Iterator<Item = &String>
Get all field names
Sourcepub fn set_field(&mut self, name: impl Into<String>, value: impl Into<String>)
pub fn set_field(&mut self, name: impl Into<String>, value: impl Into<String>)
Set a field value as string (no serde)
Sourcepub fn get_string(&self, name: &str) -> Option<&str>
pub fn get_string(&self, name: &str) -> Option<&str>
Get a field value as string (no serde)
Trait Implementations§
Source§impl Clone for ValidationContext
impl Clone for ValidationContext
Source§fn clone(&self) -> ValidationContext
fn clone(&self) -> ValidationContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ValidationContext
impl Debug for ValidationContext
Source§impl Default for ValidationContext
impl Default for ValidationContext
Source§fn default() -> ValidationContext
fn default() -> ValidationContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ValidationContext
impl !RefUnwindSafe for ValidationContext
impl Send for ValidationContext
impl Sync for ValidationContext
impl Unpin for ValidationContext
impl !UnwindSafe for ValidationContext
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