File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
src/Dotnet.Samples.AspNetCore.WebApi/Validators Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 44
55namespace Dotnet . Samples . AspNetCore . WebApi . Validators ;
66
7+ /// <summary>
8+ /// Validator for PlayerRequestModel.
9+ /// This class uses FluentValidation to define validation rules for the
10+ /// PlayerRequestModel.
11+ /// </summary>
12+ /// <remarks>
13+ /// This class is part of the FluentValidation library, which provides a fluent
14+ /// interface for building validation rules.
15+ /// </remarks>
16+ /// </summary>
717public class PlayerRequestModelValidator : AbstractValidator < PlayerRequestModel >
818{
919 public PlayerRequestModelValidator ( )
1020 {
11- RuleFor ( x => x . FirstName ) . NotEmpty ( ) . WithMessage ( "FirstName is required." ) ;
21+ RuleFor ( player => player . FirstName ) . NotEmpty ( ) . WithMessage ( "FirstName is required." ) ;
1222
13- RuleFor ( x => x . LastName ) . NotEmpty ( ) . WithMessage ( "LastName is required." ) ;
23+ RuleFor ( player => player . LastName ) . NotEmpty ( ) . WithMessage ( "LastName is required." ) ;
1424
15- RuleFor ( x => x . SquadNumber )
25+ RuleFor ( player => player . SquadNumber )
1626 . NotEmpty ( )
1727 . WithMessage ( "SquadNumber is required." )
1828 . GreaterThan ( 0 )
1929 . WithMessage ( "SquadNumber must be greater than 0." ) ;
2030
21- RuleFor ( x => x . AbbrPosition )
31+ RuleFor ( player => player . AbbrPosition )
2232 . NotEmpty ( )
2333 . WithMessage ( "AbbrPosition is required." )
2434 . Must ( Position . IsValidAbbr )
You can’t perform that action at this time.
0 commit comments