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})"); } } }