Course · Section 17: Modern JavaScript Development: Modules, Tooling, and Functional · Lecture 294: Declarative and Functional JavaScript Principles
Controlled forms compute validation errors from current values. Implement `validateForm(form)` for `{ email, password }`: add `email: 'Invalid email'` if the email lacks an `@`, and `password: 'Too short'` if the password is shorter than 6 characters. Return an errors object with only the failing fields.
+ 2 hidden tests run on Submit.
Validation derives an errors map from the current form values. Each rule adds its key only on failure, so an empty object signals a valid form and the UI can show messages just for the keys present.
Run your code to see results.