You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We would like to introduce an experimental type named DomainName, representing a domain name in the Internet, in the kotools.types.web package with the following minimum API:
interfaceDomainName {
companionobject {
val regex:Regex// Should be inaccessible for Java sources due to the unavailability of 'kotlin.text.Regex' for this language.funcreate(text:String): DomainNamefuncreateOrNull(text:String): DomainName?
}
overridefunequals(other:Any?): BooleanoverridefunhashCode(): IntoverridefuntoString(): String
}
Data validation
Accordingly to the RFC-1035, a domain name should match the following regular expression: ^(?:[A-Za-z][A-Za-z\d-]{0,61}[A-Za-z\d]\.)*[A-Za-z][A-Za-z\d-]{0,61}[A-Za-z\d]$.
Here's the explanation associated to each symbol used in this regular expression:
^Beginning. Matches the beginning of the string, or the beginning of a line if the multiline flag (m) is enabled.
(?:)Non-capturing group. Groups multiple tokens together without creating a capture group.
[]Character set. Match any character in the set.
A-ZRange. Matches a character in the range "A" to "Z" (char code 65 to 90). Case sensitive.
a-zRange. Matches a character in the range "a" to "z" (char code 97 to 122). Case sensitive.
\dDigit. Matches any digit character (0-9).
-Character. Matches a "-" character (char code 45).
{0,61}Quantifier. Match between 0 and 61 of the preceding token.
\.Escaped character. Matches a "." character (char code 46).
$End. Matches the end of the string, or the end of a line if the multiline flag (m) is enabled.
Here's an example of calling the create(String) function with a valid input from Kotlin code:
val domain:DomainName=DomainName.create("kotools.org")
println(domain) // types.kotools.org
📝 Description
We would like to introduce an experimental type named
DomainName
, representing a domain name in the Internet, in thekotools.types.web
package with the following minimum API:Data validation
Accordingly to the RFC-1035, a domain name should match the following regular expression:
^(?:[A-Za-z][A-Za-z\d-]{0,61}[A-Za-z\d]\.)*[A-Za-z][A-Za-z\d-]{0,61}[A-Za-z\d]$
.Here's the explanation associated to each symbol used in this regular expression:
^
Beginning. Matches the beginning of the string, or the beginning of a line if the multiline flag (m) is enabled.(?:)
Non-capturing group. Groups multiple tokens together without creating a capture group.[]
Character set. Match any character in the set.A-Z
Range. Matches a character in the range "A" to "Z" (char code 65 to 90). Case sensitive.a-z
Range. Matches a character in the range "a" to "z" (char code 97 to 122). Case sensitive.\d
Digit. Matches any digit character (0-9).-
Character. Matches a "-" character (char code 45).{0,61}
Quantifier. Match between 0 and 61 of the preceding token.\.
Escaped character. Matches a "." character (char code 46).$
End. Matches the end of the string, or the end of a line if the multiline flag (m) is enabled.Here's an example of calling the
create(String)
function with a valid input from Kotlin code:Serialization and deserialization
The serialization and the deserialization processes of this type should behave like for the String type.
Here's an example of Kotlin code that encodes and decodes this type using the JavaScript Object Notation (JSON) format from kotlinx.serialization:
🔗 Dependencies
This issue is blocked by the following items:
EmailAddress
syntax should follow RFC-5322 #394✅ Checklist
regex
property, test its behavior with Kotlin, update the public API binaries.EmailAddress.Companion.regex
property for using the newDomainName.Companion.regex
property, update the unreleased changelog.create(String)
function, test its behavior with Kotlin and its compatibility with Java, update the public API binaries and the unreleased changelog.createOrNull(String)
function, test its behavior with Kotlin and its compatibility with Java, update the public API binaries.toString()
function, test its behavior with Kotlin and its compatibility with Java, update the public API binaries.equals(Any?)
andhashCode()
functions, test their behavior with Kotlin and their compatibility with Java, update the public API binaries.The text was updated successfully, but these errors were encountered: