This assignment is an exercise in validating user input and using string manipulation to edit and reformat input into a preferred format. Some fields have patterns, some expect numeric values … possibly with limits. Some fields are required (and cannot be just spaces), some are optional or conditionally optional, some will cause abends if null is not expected. Some strings need to be trimmed of leading and trailing blanks, shifted to upper- or lower-case or capitalized.
Create a Validation Helperclass with the following static methods:
Capitalize– this takes a string parameter and returns a string. It should convert an incoming null string to an empty one, trim any leading & trailing spaces, shift it to lower case and then capitalize each word in the string. Beware of 1-letter words.
You must implement this method fully yourself - i.e. do not use an existing method for this task.
this takes a string and returns a Boolean. If the incoming string is null or an empty string, return false. Otherwise, return true only if the string’s entire content matches the Canadian postal pattern “A2A 2A2” … accept upper or lowercase, with or without the single space.
IsValidProvinceCode– this takes a string and returns a Boolean. If the incoming string is null or an empty string, return false. Otherwise, return true only if the string matches one of the valid 2 letter province or territory codes.
this also takes a string and returns a Boolean. If the incoming string is null or empty, return false. Otherwise, return true only if the entire string fits the phone pattern “123-123-1234”, with or without the dashes.
Create aform that allows users to book Car Maintenance appointments. The focus is on validating user input and reformatting it when it isn’t in the preferred format. The following screenshot illustrates what the form should look like:
Perform the following validations (all fields are optional unless specified otherwise). All error messages are to be shown at once, one line per error, and focus should be moved to the first field in error.
The customername is required and cannot be just blanks.
If an email is provided, the postal information (address, city, province code, and postal code) is optional. If email is not provided, the postal information is required. All four are fine, but not mandatory, whenan email is provided.
The province code, if provided, must be exactly two letters, not just two characters, and must match a valid Canadian province or territory code. Accept upper- and lowercase.
1. Use your IsValidProvinceCodemethod to verify the province code.
2. Use your IsValidPostalCodemethod to verify the postal code, if one is provided.
3. Either a home or cell phone must be provided … both are fine, but not mandatory.
4. Use your IsValidPhoneNumbermethod to verify the phone number(s).
5. The email must be a valid email pattern if provided. Note, there’s a MailAddress class in the Net.Mail 6.namespace that throws an exception when instantiatedwith an invalid email address. There’s also a plethora of indecipherable regular expressions out there.
7. Make & model is required and cannot be just blanks.
8. Year is optional but, if present, must be a valid integer value between 1900 and the current year plus one. For example, if the current year is 2021, then a valid year is any number between 1900 and 2022 inclusively.
9. The appointment date is required and cannot be in the past.
a. Use your Capitalize method to capitalize the customer’s name, the address, make & model, and city. It should not abend if any of these are null/empty.
b. Shift the province code to uppercase.
c. Shift the postal code to upper case and insert a single space if there isn’t one already.
d. Insert the dashes into the phone numbers, if they are not there already.
e. Shift the email to lowercase (it’s still valid, but easier to use for comparisons).
f. Display the date in the format shown.
Bundle and upload your solution folder to the assignment drop-box on eConestoga as a single zip file. You may submit multiple versions but only the last (i.e.most recent) submission will be looked at and graded.
Please see the marking sheet that accompanies the assignment. It will be used to calculate your grade so be sure that you are meeting all the criteria included there. Please ensure that you submit only your own work! Remember - all your code submissions will be run through MOSS, the software plagiarism detection tool.