pub enum Transformation {
Trim,
Lowercase,
Uppercase,
RemoveWhitespace,
Regex {
pattern: String,
replacement: String,
},
RegexExtract {
pattern: String,
group: usize,
},
Coerce {
target_type: String,
},
Filter {
pattern: String,
},
NormalizeWhitespace,
StripHtml,
DecodeHtml,
ParseJson,
}Expand description
A transformation to apply to extracted values
Transformations are chained in order to clean, normalize, and validate extracted data.
Variants§
Trim
Trim whitespace from start and end
Lowercase
Convert to lowercase
Uppercase
Convert to uppercase
RemoveWhitespace
Remove all whitespace
Regex
Replace using a regex pattern
RegexExtract
Extract using a regex capture group
Coerce
Coerce to a specific type
Filter
Keep only if matches a regex pattern
NormalizeWhitespace
Replace multiple consecutive whitespace with single space
StripHtml
Remove HTML tags
DecodeHtml
Decode HTML entities
ParseJson
Parse JSON string into object
Implementations§
Source§impl Transformation
impl Transformation
Sourcepub fn apply(&self, value: &str) -> Result<String>
pub fn apply(&self, value: &str) -> Result<String>
Apply this transformation to a value
§Errors
Returns crate::error::PluginError::InvalidTransformation when the
transformation has an invalid regex pattern, an unknown Coerce
target type, or an unparseable input (e.g. numeric coercion on a
non-numeric value). Returns
crate::error::PluginError::ExtractionError when a Filter
rejects the value or a RegexExtract pattern does not match.
Sourcepub fn apply_chain(transformations: &[Self], value: String) -> Result<String>
pub fn apply_chain(transformations: &[Self], value: String) -> Result<String>
Apply a chain of transformations to a value
§Errors
Propagates any crate::error::PluginError raised by the first
failing transformation in the chain — see Transformation::apply
for the per-variant failure modes.
Trait Implementations§
Source§impl Clone for Transformation
impl Clone for Transformation
Source§fn clone(&self) -> Transformation
fn clone(&self) -> Transformation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more