Skip to content

Safe error handling for rule-based type customization #228

@chaddaksha

Description

@chaddaksha

Hi,

I'm trying to automatically map protobuf types to refined types. Is it possible to do so in a safe way that would allow for easy error handling (i.e., as opposed to throwing)?

For example, Validator[MyType].validate(request) returns a list of failures when validate_at_construction is set to false. I would like similar behavior for type mappers.

One workaround I can think of is to avoid type mapping and instead just use the Validator instance, then perform unsafe operations (NonEmptyString.unsafeFrom), assuming the data has already been validated based on the appropriate rules.

Thank you,
Chad Daksha

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions