[][src]Trait csv_sanity::transformer::TransformResultHelper

pub trait TransformResultHelper {
    fn present(value: &str) -> TransformResult { ... }
fn excluded() -> TransformResult { ... }
fn error(
        field_value: &str,
        field_name: &str,
        record_n: usize,
        reason: &str
    ) -> TransformResult { ... } }

Helper trait with a few useful utility methods for constructing TransformResult.

Provided methods

fn present(value: &str) -> TransformResult

Construct a TransformResult that represents a successful transformation of a CSV record's field with a non-empty value.

fn excluded() -> TransformResult

Construct a TransformResult that represents a successful tranformation of a CSV record's field with an empty value.

fn error(
    field_value: &str,
    field_name: &str,
    record_n: usize,
    reason: &str
) -> TransformResult

Construct a TransformResult that represents a failed transformation of a CSV record's field with a descritive error reason.

An error reason should be a short, single sentence without punctuation or capitization, e.g. "not a valid email address" instead of "The email address was invalid.".

use csv_sanity::transformer::{
    TransformResult,
    TransformError,
    TransformResultHelper,
};

let result = TransformResult::error("jak,.@hot mail.com", "Email", 0, "not a valid email address");
assert_eq!(result, Err(TransformError {
    field_value: "jak,.@hot mail.com".to_string(),
    field_name: "Email".to_string(),
    record_n: 0,
    reason: "not a valid email address".to_string(),
}));
Loading content...

Implementors

impl TransformResultHelper for TransformResult[src]

fn present(value: &str) -> TransformResult[src]

fn excluded() -> TransformResult[src]

fn error(
    field_value: &str,
    field_name: &str,
    record_n: usize,
    reason: &str
) -> TransformResult
[src]

Loading content...