fabian-hiller / valibot

The modular and type safe schema library for validating structural data 🤖
https://valibot.dev
MIT License
6.33k stars 204 forks source link

add more valid/invalid cases in `ipv4` action's tests #848

Closed EltonLobo07 closed 3 weeks ago

pkg-pr-new[bot] commented 1 month ago

Open in Stackblitz

pnpm add https://pkg.pr.new/valibot@848

commit: cd70108

EltonLobo07 commented 1 month ago

Do you think I have covered the majority of the cases? If not, can you help me understand what you mean by cover all possible scenarios based on the regex used?

fabian-hiller commented 1 month ago

This is our IP v4 regex:

/^(?:(?:[1-9]|1\d|2[0-4])?\d|25[0-5])(?:\.(?:(?:[1-9]|1\d|2[0-4])?\d|25[0-5])){3}$/u

The idea is basically to test the entire regex definition, so if we accidentally change the regex in the future, our tests should fail and warn us.

For example, if a regex contains the pattern [3-6], we should have a positive test for 3, 6, and optionally a value in between, and a negative test for 2 and 7.

fabian-hiller commented 1 month ago

Thank you very much! I am busy this weekend, but I will try to review it next week.

EltonLobo07 commented 1 month ago

I think I can improve the added test cases. I'll let you know once I am done (probably tomorrow) so that you can review the changes then.

EltonLobo07 commented 1 month ago

Updated. Feel free to review the PR.