Skip to content

Commit

Permalink
make validators private
Browse files Browse the repository at this point in the history
  • Loading branch information
Barsonax committed Apr 28, 2024
1 parent 29c0f49 commit d03d097
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions CleanAspCore/Features/Departments/Endpoints/AddDepartments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public static async Task<CreatedAtRoute> Handle(HrContext context, CreateDepartm
Name = department.Name,
City = department.City
};
}

public class CreateDepartmentRequestValidator : AbstractValidator<CreateDepartmentRequest>
{
public CreateDepartmentRequestValidator()
private class CreateDepartmentRequestValidator : AbstractValidator<CreateDepartmentRequest>
{
RuleFor(x => x.Name).NotEmpty();
RuleFor(x => x.City).NotEmpty();
public CreateDepartmentRequestValidator()
{
RuleFor(x => x.Name).NotEmpty();
RuleFor(x => x.City).NotEmpty();
}
}
}
14 changes: 7 additions & 7 deletions CleanAspCore/Features/Employees/Endpoints/AddEmployee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ internal static async Task<CreatedAtRoute> Handle([FromBody] CreateEmployeeReque
DepartmentId = employee.DepartmentId,
JobId = employee.JobId
};
}

public class CreateEmployeeRequestValidator : AbstractValidator<CreateEmployeeRequest>
{
public CreateEmployeeRequestValidator()
private class CreateEmployeeRequestValidator : AbstractValidator<CreateEmployeeRequest>
{
RuleFor(x => x.FirstName).NotEmpty();
RuleFor(x => x.LastName).NotEmpty();
RuleFor(x => x.Email).EmailAddress().NotNull();
public CreateEmployeeRequestValidator()
{
RuleFor(x => x.FirstName).NotEmpty();
RuleFor(x => x.LastName).NotEmpty();
RuleFor(x => x.Email).EmailAddress().NotNull();
}
}
}
10 changes: 5 additions & 5 deletions CleanAspCore/Features/Jobs/Endpoints/AddJobs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ internal static async Task<CreatedAtRoute> Handle([FromBody] CreateJobRequest cr
Id = Guid.NewGuid(),
Name = createJobRequest.Name
};
}

public class CreateJobRequestValidator : AbstractValidator<CreateJobRequest>
{
public CreateJobRequestValidator()
private class CreateJobRequestValidator : AbstractValidator<CreateJobRequest>
{
RuleFor(x => x.Name).NotEmpty();
public CreateJobRequestValidator()
{
RuleFor(x => x.Name).NotEmpty();
}
}
}
2 changes: 1 addition & 1 deletion CleanAspCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme);

builder.Services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
builder.Services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly(), includeInternalTypes: true);
builder.Services.AddDbContext<HrContext>();

var app = builder.Build();
Expand Down

0 comments on commit d03d097

Please sign in to comment.