Skip to content

Fix frontend IP/domain validators #1727

@j-chmielewski

Description

@j-chmielewski

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.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status

Ready to release

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions