Skip to content

Add ValidationError constructor that accepts identifier and error message #208

@gordysc

Description

@gordysc

Aloha!

There appears to be a good amount of overlap between FluentValidation's ValidationFailure and this project's ValidationError class. One slight difference is the ValidationFailure class has a constructor that accepts a property name and error message. Thoughts on adding something similar to the ValidationError class in this repository? I'm not suggesting modifying any of the current constructors, but simply adding one that accepts these two values:

public ValidationError(string identifier, string errorMessage)
{
    this.Identifier = identifier;
    this.ErrorMessage = errorMessage;
}

This would simplify the following code:

// Current state
new ValidationError(nameof(Model.Name), "Name is required.", "", ValidationSeverity.Error);
// Proposed enhancement
new ValidationError(nameof(Model.Name), "Name is required.")

If you approve of the above enhancement I'd be happy to open a PR! Cheers!

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