5
Validating Form Data
Now that our system is accepting new birthdays, we need to validate the data coming in. In this chapter, we’ll see how we can test-drive the SvelteKit fail function to return useful information to the user so that they can correct any errors.
Figure 5.1 shows what is displayed to the user after the server has deemed their date of birth invalid. Notice how the invalid form data is maintained so that the user has a chance to correct it:
Figure 5.1 – A validation error is shown when entering an invalid date
This chapter covers the following key topics:
- Adding a Playwright test for validating form errors
- Displaying SvelteKit ...
Get Svelte with Test-Driven Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.