August 2018
Intermediate to advanced
298 pages
5h 33m
English
Scenario
Your company wants you to add a new validation rule for designation so that it consists of at least two words. (Hint: use regex.)
Aim
Add a new validation rule for the designation property.
Steps for completion
Revise the designation property in EmployeeAddViewModel.cs, as follows:
[Required(ErrorMessage = "Employee Designation is required")][MinLength(5, ErrorMessage = "Minimum length of designation should be 5 characters")][RegularExpression(@"^[a-z]+(?:\s[a-z]+)+$", ErrorMessage = "Designation should be at least twowords")]public string Designation { get; set; }
Read now
Unlock full access