Skip to content

Commit 050c0f9

Browse files
Clean up the validation msgs.
1 parent f3c4093 commit 050c0f9

File tree

13 files changed

+44
-83
lines changed

13 files changed

+44
-83
lines changed

Course/src/Course.API/appsettings.json

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,9 @@
44
},
55
"AppSettings": {
66
"LongRunningProcessMilliseconds": "1500",
7-
"MSG_USER_NULLUSERID": "User ID is required!",
8-
"MSG_USER_NULLFIRSTNAME": "First Name is required!",
9-
"MSG_USER_NULLLASTNAME": "Last Name is required!",
10-
"MSG_USER_NULLDOB": "Date of birth is required!",
11-
"MSG_USER_NULLGENDER": "Gender is required!",
12-
"MSG_USER_GENDER_LEN": "Gender can be only M/F!",
13-
"MSG_USER_NULLEMAILADDR": "Email Address is required!",
14-
"MSG_USER_NULLPHNUM": "Phone Number is required!",
15-
"MSG_USER_NULLCITY": "City is required!",
16-
"MSG_USER_NULLSTATE": "State is required!",
17-
"MSG_USER_NULLCOUNTRY": "Country is required!"
7+
"MSG_COURSE_COURSENAME": "Course Name is required!",
8+
"MSG_COURSE_NULLCREDITHOUR": "Credit Hour is required!",
9+
"MSG_COURSE_COURSEID": "Course ID is required!"
1810
},
1911
"Logging": {
2012
"LogLevel": {

Course/src/Course.Application/Common/Interfaces/IConfigConstants.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,8 @@ public interface IConfigConstants
55
string CourseConnection { get; }
66
string TestFullStackConnection { get; }
77
int LongRunningProcessMilliseconds { get; }
8-
string MSG_USER_NULLUSERID { get; }
9-
string MSG_USER_NULLFIRSTNAME { get; }
10-
string MSG_USER_NULLLASTNAME { get; }
11-
string MSG_USER_NULLDOB { get; }
12-
string MSG_USER_NULLGENDER { get; }
13-
string MSG_USER_GENDER_LEN { get; }
14-
string MSG_USER_NULLEMAILADDR { get; }
15-
string MSG_USER_NULLPHNUM { get; }
16-
string MSG_USER_NULLCITY { get; }
17-
string MSG_USER_NULLSTATE { get; }
18-
string MSG_USER_NULLCOUNTRY { get; }
8+
string MSG_COURSE_COURSENAME { get; }
9+
string MSG_COURSE_NULLCREDITHOUR { get; }
10+
string MSG_COURSE_COURSEID { get; }
1911
}
2012
}

Course/src/Course.Application/Course/Commands/AddCourseCommandValidator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ public class AddCourseCommandValidator : AbstractValidator<AddCourseCommand>
77
{
88
public AddCourseCommandValidator(IConfigConstants constant)
99
{
10-
this.RuleFor(v => v.CourseName).NotEmpty().WithMessage(constant.MSG_USER_NULLFIRSTNAME);
11-
this.RuleFor(v => v.CreditHour).GreaterThan(0).WithMessage(constant.MSG_USER_NULLLASTNAME);
10+
this.RuleFor(v => v.CourseName).NotEmpty().WithMessage(constant.MSG_COURSE_COURSENAME);
11+
this.RuleFor(v => v.CreditHour).GreaterThan(0).WithMessage(constant.MSG_COURSE_NULLCREDITHOUR);
1212
}
1313
}
14-
}
14+
}

Course/src/Course.Application/Course/Commands/DeleteCourseCommandValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class DeleteCourseCommandValidator : AbstractValidator<DeleteCourseComman
66
{
77
public DeleteCourseCommandValidator(IConfigConstants constant)
88
{
9-
this.RuleFor(v => v.CourseID).GreaterThan(0).WithMessage(constant.MSG_USER_NULLUSERID);
9+
this.RuleFor(v => v.CourseID).GreaterThan(0).WithMessage(constant.MSG_COURSE_COURSEID);
1010
}
1111
}
12-
}
12+
}

Course/src/Course.Application/Course/Commands/UpdateCourseCommandValidator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ public class UpdateCourseCommandValidator : AbstractValidator<UpdateCourseComman
66
{
77
public UpdateCourseCommandValidator(IConfigConstants constant)
88
{
9-
this.RuleFor(v => v.CourseName).NotEmpty().WithMessage(constant.MSG_USER_NULLFIRSTNAME);
10-
this.RuleFor(v => v.CreditHour).GreaterThan(0).WithMessage(constant.MSG_USER_NULLLASTNAME);
9+
this.RuleFor(v => v.CourseName).NotEmpty().WithMessage(constant.MSG_COURSE_COURSENAME);
10+
this.RuleFor(v => v.CreditHour).GreaterThan(0).WithMessage(constant.MSG_COURSE_NULLCREDITHOUR);
1111
}
1212
}
13-
}
13+
}

Course/src/Course.Application/Course/Queries/GetSingleCourseQueryValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class GetSingleCourseQueryValidator : AbstractValidator<GetSingleCourseQu
66
{
77
public GetSingleCourseQueryValidator(IConfigConstants constant)
88
{
9-
this.RuleFor(v => v.CourseID).GreaterThan(0).WithMessage(constant.MSG_USER_NULLUSERID);
9+
this.RuleFor(v => v.CourseID).GreaterThan(0).WithMessage(constant.MSG_COURSE_COURSEID);
1010
}
1111
}
12-
}
12+
}

Course/src/Course.Persistence/Constant/ConfigConstants.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@ public ConfigConstants(IConfiguration configuration)
1414
public string TestFullStackConnection => this.Configuration.GetConnectionString("TestFullStackConnection");
1515
public int LongRunningProcessMilliseconds => int.Parse(this.Configuration["AppSettings:LongRunningProcessMilliseconds"]);
1616

17-
public string MSG_USER_NULLUSERID => this.Configuration["AppSettings:MSG_USER_NULLUSERID"];
18-
public string MSG_USER_NULLFIRSTNAME => this.Configuration["AppSettings:MSG_USER_NULLFIRSTNAME"];
19-
public string MSG_USER_NULLLASTNAME => this.Configuration["AppSettings:MSG_USER_NULLLASTNAME"];
20-
public string MSG_USER_NULLDOB => this.Configuration["AppSettings:MSG_USER_NULLDOB"];
21-
public string MSG_USER_NULLGENDER => this.Configuration["AppSettings:MSG_USER_NULLGENDER"];
22-
public string MSG_USER_GENDER_LEN => this.Configuration["AppSettings:MSG_USER_GENDER_LEN"];
23-
public string MSG_USER_NULLEMAILADDR => this.Configuration["AppSettings:MSG_USER_NULLEMAILADDR"];
24-
public string MSG_USER_NULLPHNUM => this.Configuration["AppSettings:MSG_USER_NULLPHNUM"];
25-
public string MSG_USER_NULLCITY => this.Configuration["AppSettings:MSG_USER_NULLCITY"];
26-
public string MSG_USER_NULLSTATE => this.Configuration["AppSettings:MSG_USER_NULLSTATE"];
27-
public string MSG_USER_NULLCOUNTRY => this.Configuration["AppSettings:MSG_USER_NULLCOUNTRY"];
17+
public string MSG_COURSE_COURSENAME => this.Configuration["AppSettings:MSG_COURSE_COURSENAME"];
18+
19+
public string MSG_COURSE_NULLCREDITHOUR => this.Configuration["AppSettings:MSG_COURSE_NULLCREDITHOUR"];
20+
21+
public string MSG_COURSE_COURSEID => this.Configuration["AppSettings:MSG_COURSE_COURSEID"];
22+
2823
}
2924
}

StudentCourse/src/StudentCourse.API/appsettings.json

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,9 @@
44
},
55
"AppSettings": {
66
"LongRunningProcessMilliseconds": "1500",
7-
"MSG_USER_NULLUSERID": "User ID is required!",
8-
"MSG_USER_NULLFIRSTNAME": "First Name is required!",
9-
"MSG_USER_NULLLASTNAME": "Last Name is required!",
10-
"MSG_USER_NULLDOB": "Date of birth is required!",
11-
"MSG_USER_NULLGENDER": "Gender is required!",
12-
"MSG_USER_GENDER_LEN": "Gender can be only M/F!",
13-
"MSG_USER_NULLEMAILADDR": "Email Address is required!",
14-
"MSG_USER_NULLPHNUM": "Phone Number is required!",
15-
"MSG_USER_NULLCITY": "City is required!",
16-
"MSG_USER_NULLSTATE": "State is required!",
17-
"MSG_USER_NULLCOUNTRY": "Country is required!"
7+
"MSG_COURSE_COURSENAME": "Course Name is required!",
8+
"MSG_COURSE_NULLCREDITHOUR": "Credit Hour is required!",
9+
"MSG_COURSE_COURSEID": "Course ID is required!"
1810
},
1911
"Logging": {
2012
"LogLevel": {

StudentCourse/src/StudentCourse.Application/Common/Interfaces/IConfigConstants.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,10 @@ public interface IConfigConstants
55
string StudentCourseConnection { get; }
66
string TestFullStackConnection { get; }
77
int LongRunningProcessMilliseconds { get; }
8-
string MSG_USER_NULLUSERID { get; }
9-
string MSG_USER_NULLFIRSTNAME { get; }
10-
string MSG_USER_NULLLASTNAME { get; }
11-
string MSG_USER_NULLDOB { get; }
12-
string MSG_USER_NULLGENDER { get; }
13-
string MSG_USER_GENDER_LEN { get; }
14-
string MSG_USER_NULLEMAILADDR { get; }
15-
string MSG_USER_NULLPHNUM { get; }
16-
string MSG_USER_NULLCITY { get; }
17-
string MSG_USER_NULLSTATE { get; }
18-
string MSG_USER_NULLCOUNTRY { get; }
8+
string MSG_COURSE_COURSENAME { get; }
9+
string MSG_COURSE_NULLCREDITHOUR { get; }
10+
string MSG_COURSE_COURSEID { get; }
11+
12+
string MSG_SC_NULLStdCourseID { get; }
1913
}
2014
}

StudentCourse/src/StudentCourse.Application/StudentCourse/Commands/DeleteStudentCourseCommandValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class DeleteStudentCourseCommandValidator : AbstractValidator<DeleteStude
77
{
88
public DeleteStudentCourseCommandValidator(IConfigConstants constant)
99
{
10-
this.RuleFor(v => v.StudentCourseID).GreaterThan(0).WithMessage(constant.MSG_USER_NULLUSERID);
10+
this.RuleFor(v => v.StudentCourseID).GreaterThan(0).WithMessage(constant.MSG_SC_NULLStdCourseID);
1111
}
1212
}
13-
}
13+
}

StudentCourse/src/StudentCourse.Application/StudentCourse/Commands/UpdateStudentCourseCommandValidator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ public class UpdateStudentCourseCommandValidator : AbstractValidator<UpdateStude
77
{
88
public UpdateStudentCourseCommandValidator(IConfigConstants constant)
99
{
10-
this.RuleFor(v => v.CourseName).NotEmpty().WithMessage(constant.MSG_USER_NULLFIRSTNAME);
11-
this.RuleFor(v => v.CreditHour).GreaterThan(0).WithMessage(constant.MSG_USER_NULLLASTNAME);
10+
this.RuleFor(v => v.CourseName).NotEmpty().WithMessage(constant.MSG_COURSE_COURSENAME);
11+
this.RuleFor(v => v.CreditHour).GreaterThan(0).WithMessage(constant.MSG_COURSE_NULLCREDITHOUR);
1212
}
1313
}
14-
}
14+
}

StudentCourse/src/StudentCourse.Application/StudentCourse/Queries/GetSingleStudentCourseQueryValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class GetSingleStudentCourseQueryValidator : AbstractValidator<GetSingleS
77
{
88
public GetSingleStudentCourseQueryValidator(IConfigConstants constant)
99
{
10-
this.RuleFor(v => v.CourseID).GreaterThan(0).WithMessage(constant.MSG_USER_NULLUSERID);
10+
this.RuleFor(v => v.CourseID).GreaterThan(0).WithMessage(constant.MSG_COURSE_COURSEID);
1111
}
1212
}
13-
}
13+
}

StudentCourse/src/StudentCourse.Persistence/Constant/ConfigConstants.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@ public ConfigConstants(IConfiguration configuration)
1515
public string TestFullStackConnection => this.Configuration.GetConnectionString("TestFullStackConnection");
1616
public int LongRunningProcessMilliseconds => int.Parse(this.Configuration["AppSettings:LongRunningProcessMilliseconds"]);
1717

18-
public string MSG_USER_NULLUSERID => this.Configuration["AppSettings:MSG_USER_NULLUSERID"];
19-
public string MSG_USER_NULLFIRSTNAME => this.Configuration["AppSettings:MSG_USER_NULLFIRSTNAME"];
20-
public string MSG_USER_NULLLASTNAME => this.Configuration["AppSettings:MSG_USER_NULLLASTNAME"];
21-
public string MSG_USER_NULLDOB => this.Configuration["AppSettings:MSG_USER_NULLDOB"];
22-
public string MSG_USER_NULLGENDER => this.Configuration["AppSettings:MSG_USER_NULLGENDER"];
23-
public string MSG_USER_GENDER_LEN => this.Configuration["AppSettings:MSG_USER_GENDER_LEN"];
24-
public string MSG_USER_NULLEMAILADDR => this.Configuration["AppSettings:MSG_USER_NULLEMAILADDR"];
25-
public string MSG_USER_NULLPHNUM => this.Configuration["AppSettings:MSG_USER_NULLPHNUM"];
26-
public string MSG_USER_NULLCITY => this.Configuration["AppSettings:MSG_USER_NULLCITY"];
27-
public string MSG_USER_NULLSTATE => this.Configuration["AppSettings:MSG_USER_NULLSTATE"];
28-
public string MSG_USER_NULLCOUNTRY => this.Configuration["AppSettings:MSG_USER_NULLCOUNTRY"];
18+
public string MSG_COURSE_COURSENAME => this.Configuration["AppSettings:MSG_COURSE_COURSENAME"];
19+
20+
public string MSG_COURSE_NULLCREDITHOUR => this.Configuration["AppSettings:MSG_COURSE_NULLCREDITHOUR"];
21+
22+
public string MSG_COURSE_COURSEID => this.Configuration["AppSettings:MSG_COURSE_COURSEID"];
23+
24+
public string MSG_SC_NULLStdCourseID => this.Configuration["AppSettings:MSG_SC_NULLStdCourseID"];
2925
}
3026
}

0 commit comments

Comments
 (0)