Closed sunnymui closed 5 years ago
To resolve merge conflicts, I just defaulted every conflict to newer written code.
Since I wrote updated validation utilities for an older version of the posting logic, I just took out the usage of the validation utility functions for now in the updated logic. Things for the admincontainer were were moved around into separate files (adminform.js) so I'll leave implementing the utilities into the actual in-use logic for a future commit.
Should just have to look at the validateField function in adminForm.js, around line 81 - 120 and replace the if statements with lookups in the validation utilties.
The actual utility functions are in the separate validationUtilities.js file.
Refactored
validatePostDetails
in AdminContainer.js to pull the corresponding validation function from a hash table of validation utility functions. Also avoids doing spread operations every time the reduce callback is executed to build the accumulated errors object with a more hash table construction style.Validation logic for each
postField
that was happening in the if statements was moved to individual validation functions in the validationUtilities.js file. It's now grouped in the theisInvalid
object. Had to add the option to callisInvalid
functions with a default which works if apostField
does not have a specifically defined validation.Expanded some of the validations:
&&
to||
in the email check, assuming it should check if empty field OR if an invalid email formatWanted to make sure I didn't mess anything up so I added 8 unit tests in AdminContainer.test.js to check that everything was validating as expected and to check that all the stuff I changed didn't break something. I just checked it by running
npm test
I also had to reinstall the dependencies to make it run. I think a module got added on the dev branch that I didn't have on my repo so I had to add it.