exercise 3 from https://tddmanifesto.com/exercises/
Create a function that can be used as a validator for the password field of a user registration form. The validation function takes a string as an input and returns a validation result. The validation result should contain a boolean indicating if the password is valid or not, and also a field with the possible validation errors.
Requirements
-
The password must be at least 8 characters long. If it is not met, then the following error message should be returned: “Password must be at least 8 characters”
-
The password must contain at least 2 numbers. If it is not met, then the following error message should be returned: “The password must contain at least 2 numbers”
-
The validation function should handle multiple validation errors.
For example, “somepassword” should an error message: “Password must be at least 8 characters\nThe password must contain at least 2 numbers” 4. The password must contain at least one capital letter. If it is not met, then the following error message should be returned: “password must contain at least one capital letter”
- The password must contain at least one special character. If it is not met, then the following error message should be returned: “password must contain at least one special character”
Part 1 : https://www.youtube.com/watch?v=A99A7ucs1A4
Part 2 : https://www.youtube.com/watch?v=I9KXBqQDQ6A
Conclusion : https://www.youtube.com/watch?v=2MY2_bvllEE