Skip to content

Commit

Permalink
Validators for locations
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryba1986 committed Jul 3, 2022
1 parent 13f8440 commit 9de3a7e
Showing 2 changed files with 36 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Zeus.Validators/Locations/CreateLocationValidator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using FluentValidation;
using Zeus.Models.Locations.Commands;
using Zeus.Validators.Base;

namespace Zeus.Validators.Locations
{
public sealed class CreateLocationValidator : AbstractValidator<CreateLocationCommand>
{
public CreateLocationValidator()
{
RuleFor(x => x.Name).NotEmpty().Length(3, 30);

RuleFor(x => x.MacAddress).NotEmpty().Matches(LocationRules.MacAddressFormat);
}
}
}
20 changes: 20 additions & 0 deletions src/Zeus.Validators/Locations/UpdateLocationValidator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using FluentValidation;
using Zeus.Models.Locations.Commands;
using Zeus.Validators.Base;

namespace Zeus.Validators.Locations
{
public sealed class UpdateLocationValidator : AbstractValidator<UpdateLocationCommand>
{
public UpdateLocationValidator()
{
RuleFor(x => x.Id).NotEmpty();

RuleFor(x => x.Name).NotEmpty().Length(3, 30);

RuleFor(x => x.MacAddress).NotEmpty().Matches(LocationRules.MacAddressFormat);

RuleFor(x => x.Version).NotEmpty();
}
}
}

0 comments on commit 9de3a7e

Please sign in to comment.