Skip to content

Schema for a domain? #967

Answered by bioball
kaihendry asked this question in Q&A
Feb 19, 2025 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

You can use a type constraint to describe what a valid domain name is.

Took this regex from https://stackoverflow.com/a/26987741:

typealias DomainName = String(matches(Regex(#"(((?!-))(xn--|_)?[a-z0-9-]{0,61}[a-z0-9]{1,1}\.)*(xn--)?([a-z0-9][a-z0-9\-]{0,60}|[a-z0-9-]{1,30}\.[a-z]{2,})"#)))

tenant: DomainName

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@kaihendry
Comment options

Answer selected by kaihendry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants