| 123456789101112131415161718192021 |
- using System.ComponentModel.DataAnnotations;
- using FluentValidation;
- namespace BlazorEditForms.Model;
- public class PhoneNumber
- {
- [Phone]
- public string Number { get; set; } = string.Empty;
- public PhoneNumberType Type { get; set; }
- }
- public class PhoneNumberValidator : AbstractValidator<PhoneNumber>
- {
- public PhoneNumberValidator()
- {
- RuleFor(x => x.Number).NotEmpty().Matches(@"\+?\d+");
- RuleFor(x => x.Type).IsInEnum();
- }
- }
|