c5375b661b
broke data out into its own library. may be breaking changes with existing plugins
34 lines
1006 B
C#
34 lines
1006 B
C#
using Data.Models;
|
|
using FluentValidation;
|
|
using SharedLibraryCore.Dtos;
|
|
|
|
namespace WebfrontCore.Controllers.API.Validation
|
|
{
|
|
/// <summary>
|
|
/// validator for FindClientRequest
|
|
/// </summary>
|
|
public class FindClientRequestValidator : AbstractValidator<FindClientRequest>
|
|
{
|
|
public FindClientRequestValidator()
|
|
{
|
|
RuleFor(_request => _request.Name)
|
|
.NotEmpty()
|
|
.When(_request => string.IsNullOrEmpty(_request.Xuid));
|
|
|
|
RuleFor(_request => _request.Name)
|
|
.MinimumLength(EFAlias.MIN_NAME_LENGTH)
|
|
.MaximumLength(EFAlias.MAX_NAME_LENGTH);
|
|
|
|
RuleFor(_request => _request.Xuid)
|
|
.NotEmpty()
|
|
.When(_request => string.IsNullOrEmpty(_request.Name));
|
|
|
|
RuleFor(_request => _request.Count)
|
|
.InclusiveBetween(1, 100);
|
|
|
|
RuleFor(_request => _request.Offset)
|
|
.GreaterThanOrEqualTo(0);
|
|
}
|
|
}
|
|
}
|