You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inside /api directory, create a /application route that performs a POST request to our database. This route will save new members' information into the database.
Acceptence Criteria
This route accept the following JSON schema, for example:
{
"full_name": "John Doe",
"email": "johndoe@mail.com",
"phone_number": "+1 123-456-7890",
"phone_type": "Home",
"mailing_address": "123 ABC Street",
"city": "Vancouver",
"province": "British Columbia""postal_code": "ABC 123",
"membership_interests": "[Health, Education]""reason": "I want to become a part of RPRC because ABC reasons"
}
Implement server-side validation for the above fields like so:
full_name: letters only, at least 2 words, each word's first letter is capitalized
email: lowercase letters only, with a valid email domain
phone_number: valid North American phone number, automatically attach a +1 country code before the number itself. Numbers only
phone_type: accept two values only: either Home or Cell
mailing_address: include street number, street's name and optionally, unit number if one lives in an apartment
city: valid city name in Canada
province: valid province name in Canada
postal_code: has a length of 7, including 3 letters at the start, one space in between and 3 digits that follows
membership_interests: accepts an array of values. MUST match with these values ONLY: Health, Education, Entertainment, Arts+Culture, Housing, Other
reason: perhaps limit the word count to 100-200?
Every field: trim white spaces on both side and check if it's empty
If all fields are valid, send back this response:
{
"status": "success",
"data": null
}
If not:
{
"status": "fail",
"data": {
"full_name": "Full name must consists of at least 2 words",
"email": "Invalid email domain"
}
}
When sending a fail response, each field MUST matches with the JSON field that is being sent to database
Purpose
Inside
/apidirectory, create a/applicationroute that performs aPOSTrequest to our database. This route will save new members' information into the database.Acceptence Criteria
{ "full_name": "John Doe", "email": "johndoe@mail.com", "phone_number": "+1 123-456-7890", "phone_type": "Home", "mailing_address": "123 ABC Street", "city": "Vancouver", "province": "British Columbia" "postal_code": "ABC 123", "membership_interests": "[Health, Education]" "reason": "I want to become a part of RPRC because ABC reasons" }full_name: letters only, at least 2 words, each word's first letter is capitalizedemail: lowercase letters only, with a valid email domainphone_number: valid North American phone number, automatically attach a+1country code before the number itself. Numbers onlyphone_type: accept two values only: eitherHomeorCellmailing_address: include street number, street's name and optionally, unit number if one lives in an apartmentcity: valid city name in Canadaprovince: valid province name in Canadapostal_code: has a length of 7, including 3 letters at the start, one space in between and 3 digits that followsmembership_interests: accepts an array of values. MUST match with these values ONLY:Health,Education,Entertainment,Arts+Culture,Housing,Otherreason: perhaps limit the word count to 100-200?{ "status": "success", "data": null }If not:
{ "status": "fail", "data": { "full_name": "Full name must consists of at least 2 words", "email": "Invalid email domain" } }When sending a fail response, each field MUST matches with the JSON field that is being sent to database
Additional Comments