validateIpOrDomain does too many things, is used in too many places and currently doesn't work in all of them.
- ipv4 validation with/without mask and with/without port
- ipv6 validation with/without mask and with/without port
- domain validation with/without port
On top of that domain validation regex includes ports too, so it's not possible to validate "domain without port".
Solution
Split the existing validator into a set of single-responsibility validators:
- ipv4
- ipv4WithPort
- ipv6
- ipv6WithPort
- cidrv4
- cidrv6
- domain
- domainWithPort
These can then be composed directly in Zod schemas to construct the exact validation behavior needed for each field.
While working on this issue, please also setup a unit-testing framework for the frontend and implement unit-tests for the validators.
validateIpOrDomain does too many things, is used in too many places and currently doesn't work in all of them.
On top of that domain validation regex includes ports too, so it's not possible to validate "domain without port".
Solution
Split the existing validator into a set of single-responsibility validators:
These can then be composed directly in Zod schemas to construct the exact validation behavior needed for each field.
While working on this issue, please also setup a unit-testing framework for the frontend and implement unit-tests for the validators.