| 1234567891011121314151617 |
- using System.ComponentModel.DataAnnotations;
- namespace bitforum.Attributes
- {
- public class MustBeTrueAttribute : ValidationAttribute
- {
- protected override ValidationResult IsValid(object? value, ValidationContext validationContext)
- {
- if (value is bool boolValue && boolValue)
- {
- return ValidationResult.Success;
- }
- return new ValidationResult(ErrorMessage ?? "값은 `true` 여야 합니다.");
- }
- }
- }
|