pub fn validate_optional(
rule: &ValidationRule,
field_value: &str,
field_name: &str,
is_present: bool,
) -> Result<()>Expand description
Validates a rule only if the field is present.
If the field is absent/null, validation is skipped (passes). If the field is present, the rule is applied normally.
§Arguments
rule- The validation rule to conditionally applyfield_value- The value being validatedfield_name- Name of the field for error reportingis_present- Whether the field is present/non-null
§Returns
Ok(())if field is absent or if rule passesErrif field is present and rule fails