You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Framework/Connected.Validation/ValidationExceptions.cs

42 lines
1.2 KiB

using System.ComponentModel.DataAnnotations;
namespace Connected.Validation
{
public static class ValidationExceptions
{
public static ValidationException ValueExists(string argument, object? value)
{
var valueString = value is null ? "null" : value;
return new ValidationException($"{SR.ValDuplicate} ({argument}, {valueString})");
}
public static ValidationException InvalidCharacter(string argument, char value)
{
return new ValidationException($"{SR.ValInvalidChars} ({argument}, {value})");
}
public static ValidationException NotFound(string argument, object? value)
{
var valueString = value is null ? "null" : value;
return new ValidationException($"{SR.ValNotFound} ({argument}, {valueString})");
}
public static ValidationException Disabled(string argument)
{
return new ValidationException($"{SR.ValEntityDisabled} ({argument})");
}
public static ValidationException ReferenceExists(Type entity, object value)
{
return new ValidationException($"{SR.ValReference} ({entity.Name}, {value})");
}
public static ValidationException Mismatch(string argument, object value)
{
return new ValidationException($"{SR.ValMismatch} ({argument}, {value})");
}
}
}