types
types copied to clipboard
✨ `Zero` instance creation from `Any`
📝 Description
We want to introduce additional factory functions for creating an instance of Zero from the string representation of Any object.
The regular expression used for validating inputs should be the following: ^(?:-|\+)?0+(?:\.0+)?$.
Here's the explanation associated to each symbol used in this pattern:
^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. Matches a "-" character (char code 45).|Alternation. Acts like a boolean OR. Matches the expression before or after the|.\+Escaped character. Matches a "+" character (char code 43).?Quantifier. Match between 0 and 1 of the preceding token.0Character. Matches a "0" character (char code 48).+Quantifier. Match 1 or more 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 the Application Programming Interface (API) goal:
interface Zero {
companion object {
const val STRING_PATTERN: String
fun fromString(number: Any): Zero
fun fromStringOrNull(number: Any): Zero?
}
}
✅ Checklist
- [ ] ✨ Add the
STRING_PATTERNproperty with tests, documentation and samples. - [ ] ✨ Add the
fromStringOrNullfunction with tests, documentation and samples. - [ ] ✨ Add the
fromStringfunction with tests, documentation and samples. - [ ] 📝 Add entry for this issue in unreleased changelog.