Skip to content

Ability to specify custom exceptions on validation errors. #29

@terminalxposure

Description

@terminalxposure

Something like this:

Implementation

public static IArg<T> WithExceptions<T>(this IArg<T> arg, Action<T, 
IEnumerable<ErrorInfo>> handleErrorsAction) where T : IComparable
        {
            if (arg.Errors.Any())
            {
                handleErrorsAction(arg.Value, arg.Errors);
            }

            return arg;
        }

Usage

var x = 1;
Validate.That(() => x).IsEqual(0).WithExceptions((value, errors) => throw new Exception());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions