| | | 1 | | using System; |
| | | 2 | | using System.ComponentModel.DataAnnotations; |
| | | 3 | | |
| | | 4 | | namespace SVETA.Api.Data |
| | | 5 | | { |
| | | 6 | | public class NotNullOrWhiteSpaceValidatorAttribute : ValidationAttribute |
| | | 7 | | { |
| | 127 | 8 | | public NotNullOrWhiteSpaceValidatorAttribute() |
| | 127 | 9 | | { |
| | | 10 | | |
| | 127 | 11 | | } |
| | | 12 | | |
| | | 13 | | public override bool IsValid(object value) |
| | 0 | 14 | | { |
| | 0 | 15 | | return !string.IsNullOrWhiteSpace((value ?? string.Empty).ToString()); |
| | 0 | 16 | | } |
| | | 17 | | |
| | | 18 | | protected override ValidationResult IsValid(Object value, ValidationContext validationContext) |
| | 0 | 19 | | { |
| | 0 | 20 | | return IsValid(value) ? ValidationResult.Success : new ValidationResult($"Поле '{validationContext.DisplayNa |
| | 0 | 21 | | } |
| | | 22 | | } |
| | | 23 | | } |