Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validator for email addresses, host names, IP addresses #12

Open
willhains opened this issue Jun 1, 2023 · 0 comments
Open

Validator for email addresses, host names, IP addresses #12

willhains opened this issue Jun 1, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@willhains
Copy link
Owner

willhains commented Jun 1, 2023

Email address validation can be tricky.
Should there be an explicit validator rule for email address strings?
There may also be some performance benefit to validate by code rather than by regex.

Proposed API

@EmailAddress
public final @Value class EmailAddress extends PureString<EmailAddress> {...}

@HostName
public final @Value class HostName extends PureString<HostName> {...}

@IPAddress
public final @Value class ServerIP extends PureString<ServerIP> {...}

Alternatives

Rather than creating separate annotations for each, provide constants for special cases:

@Matching(EMAIL_ADDRESS)
public final @Value class EmailAddress extends PureString<EmailAddress> {...}

@Matching(HOST_NAME)
public final @Value class HostName extends PureString<HostName> {...}

@Matching(IP_V4_ADDRESS)
public final @Value class ServerIP extends PureString<ServerIP> {...}

These could be well-tested regex patterns, or special constant string values that the @Matching rule checks for, and invokes non-regex logic for faster validation.

@willhains willhains added the enhancement New feature or request label Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant