public ModifyTournamentCommandValidator(IFileValidate fileValidate) { RuleFor(t => t.Name) .NotEmpty() .Length(NAME_MIN_LENGTH, NAME_MAX_LENGTH) .WithMessage(string.Format(NAME_LENGTH_MSG, NAME_MIN_LENGTH, NAME_MAX_LENGTH)); RuleFor(t => t.Description) .NotEmpty() .Length(DESC_MIN_LENGTH, DESC_MAX_LENGTH) .WithMessage(string.Format(DESC_LENGTH_MSG, DESC_MIN_LENGTH, DESC_MAX_LENGTH)); RuleFor(t => t.StartDate) .NotEmpty() .Must(t => t.DayOfWeek == DayOfWeek.Monday) .WithMessage(START_DATE_MUST_BE_MONDAY_MSG); RuleFor(t => t.EndDate) .NotEmpty() .Must(t => t.DayOfWeek == DayOfWeek.Sunday) .WithMessage(END_DATE_MUST_BE_SUNDAY_MSG) .GreaterThanOrEqualTo(t => t.StartDate.AddMonths(END_DATE_MIN_MONTH_LENGTH).AddDays(END_DATE_MAX_DAYS_DIFF).Date) .WithMessage(string.Format(END_DATE_MSG, END_DATE_MIN_MONTH_LENGTH)); When(e => e.TournamentImage != null, () => RuleFor(t => t.TournamentImage) .SetValidator(new CustomGameImageFileValidator(fileValidate))); }
public CreateTeamCommandValidator(IFileValidate fileValidate) { RuleFor(x => x.Name) .NotEmpty() .Length(NAME_MIN_LENGTH, NAME_MAX_LENGTH) .WithMessage(string.Format(NAME_LENGTH_MSG, NAME_MIN_LENGTH, NAME_MAX_LENGTH)); RuleFor(x => x.Description) .Length(DESC_MIN_LENGTH, DESC_MAX_LENGTH) .WithMessage(string.Format(DESC_LENGTH_MSG, DESC_MIN_LENGTH, DESC_MAX_LENGTH)); RuleFor(x => x.HomepageUrl) .Matches(URL_EXPRESSION) .WithMessage(URL_EXPRESSION_MSG); RuleFor(x => x.TournamentFormatId) .NotEmpty(); RuleFor(x => x.TournamentFormatId) .NotEmpty(); RuleFor(x => x.TeamImage) .NotEmpty() .SetValidator(new CustomGameImageFileValidator(fileValidate)); }
public EventsModel(ApiClient apiClient, IMapper mapper, IAzureBlob azureBlob, IFileValidate fileValidate, IAzureSASTokenUrl azureSASTokenUrl, ILogger <EventsModel> logger) { _apiClient = apiClient; _mapper = mapper; _azureBlob = azureBlob; _fileValidate = fileValidate; _azureSASTokenUrl = azureSASTokenUrl; _logger = logger; }
public ModifyGameCommandValidator(IFileValidate fileValidate) { RuleFor(x => x.Name) .Length(NAME_MIN_LENGTH, NAME_MAX_LENGTH) .NotEmpty() .WithMessage(string.Format(NAME_LENGTH_MSG, NAME_MIN_LENGTH, NAME_MAX_LENGTH)); RuleFor(x => x.Description) .Length(DESC_MIN_LENGTH, DESC_MAX_LENGTH) .NotEmpty() .WithMessage(string.Format(DESC_LENGTH_MSG, DESC_MIN_LENGTH, DESC_MAX_LENGTH)); When(g => g.GameImage != null, () => RuleFor(x => x.GameImage).SetValidator(new CustomGameImageFileValidator(fileValidate))); }
public BoardMeetingsModel(ApiClient apiClient, IMapper mapper, IAzureSASTokenUrl azureSASTokenUrl, IAzureBlob azureBlob, IFileValidate fileValidate, ILogger <BoardMeetingsModel> logger) { _apiClient = apiClient; _mapper = mapper; _azureSASTokenUrl = azureSASTokenUrl; _azureBlob = azureBlob; _fileValidate = fileValidate; _logger = logger; //need to initialize an empty object because by default the property is null //within the view, when you try and access the objects underlying properties, razor will throw an error //because the property has not been initialized MeetingToCreateEdit = new BoardMeetingManipulationDto(); FileUploaded = new RequiredFileDto(); }
public EmailValidator(IFileValidate fileValidate) { RuleFor(email => email.Message).NotNull().WithMessage("Message cannot be null") .Length(5, 1000).WithMessage("Message has to be between 5 and 1000 characters"); RuleFor(email => email.EmailFrom).NotNull().WithMessage("From email cannot be null") .EmailAddress().WithMessage("From email has to be an email address"); //might need to replace this with a custom validator RuleFor(email => email.EmailTo).NotNull().WithMessage("To email cannot be null"); RuleFor(email => email.Subject).NotNull().WithMessage("Subject cannot be null"); RuleFor(email => email.Name).NotNull().WithMessage("Name cannot be null"); RuleFor(email => email.Attachment).SetValidator(new CustomFileValidator(fileValidate, false, true)); }
public ModifyTeamCommandValidator(IFileValidate fileValidate) { RuleFor(x => x.Name) .NotEmpty() .Length(NAME_MIN_LENGTH, NAME_MAX_LENGTH) .WithMessage(string.Format(NAME_LENGTH_MSG, NAME_MIN_LENGTH, NAME_MAX_LENGTH)); RuleFor(x => x.Description) .Length(DESC_MIN_LENGTH, DESC_MAX_LENGTH) .WithMessage(string.Format(DESC_LENGTH_MSG, DESC_MIN_LENGTH, DESC_MAX_LENGTH)); RuleFor(x => x.HomepageUrl) .Matches(URL_EXPRESSION) .WithMessage(URL_EXPRESSION_MSG); When(e => e.TeamImage != null, () => RuleFor(t => t.TeamImage) .SetValidator(new CustomGameImageFileValidator(fileValidate))); }
public RequiredFileValidator(IFileValidate fileValidate) { RuleFor(file => file.FileToUpload).NotNull().SetValidator(new CustomFileValidator(fileValidate, false, false)); }
/// <summary> /// Custom validator for validating images and files.If isImage is passed as true, the file is not required. /// If isBoardEmail is passed as true, the file is not required. /// All other instances will cause the file to be required / not null /// </summary> /// <param name="fileValidate"></param> /// <param name="isImage"></param> /// <param name="isBoardEmail"></param> public CustomFileValidator(IFileValidate fileValidate, bool isImage, bool isBoardEmail) : base("{ErrorMessage}") { _fileValidate = fileValidate; _isImage = isImage; _isBoardEmail = isBoardEmail; }
public ContactBoardModel(IFileValidate fileValidate, ISendEmail sendEmail) { _fileValidate = fileValidate; _sendEmail = sendEmail; }
public OptionalFileValidator(IFileValidate fileValidate) { RuleFor(file => file.FileToUpload).SetValidator(new CustomFileValidator(fileValidate, false, true)); }
public CustomGameImageFileValidator(IFileValidate fileValidate) : base("{ErrorMessage}") { this.fileValidate = fileValidate; }
public ObjectBValidator(IFileValidate fileValidate) { RuleFor(file => file.FileToUpload).SetValidator(new CustomFileValidator(fileValidate)); }
public CustomFileValidator(IFileValidate fileValidate) : base("{ErrorMessage}") { _fileValidate = fileValidate; }