Added LICENSE
Custom data type for representing basketball player numbers with additional validation rules.
init?(number: String) - initializes correctly with a positive number comprised of one or two digits.
init?(number: String)
Allowed numbers: 00, 01…09, 0…99.
You can use init?(number: String, validationRules: Set<JerseyNumberValidationRule>) to restrict valid numbers.
init?(number: String, validationRules: Set<JerseyNumberValidationRule>)
JerseyNumberValidationRule
.only0to5 - returns nil if number contains digits in range of 6...9 in any place
.only0to5
nil
number
6...9
.doubleZeroNotAllowed - returns nil if number is "00"
.doubleZeroNotAllowed
"00"
.noLeadingZeros - returns nil for values like 01…09
.noLeadingZeros
copy(usingValidationRules rules: Set<JerseyNumberValidationRule>) -> BasketballJerseyNumber? - makes a copy by following all provided rules.
copy(usingValidationRules rules: Set<JerseyNumberValidationRule>) -> BasketballJerseyNumber?
follows(rules: Set<JerseyNumberValidationRule>) -> Bool - verifies the number against a set of provided rules.
follows(rules: Set<JerseyNumberValidationRule>) -> Bool
Conforms to Hashable and CustomStringConvertible.
Hashable
CustomStringConvertible
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
BasketballJerseyNumber
Custom data type for representing basketball player numbers with additional validation rules.
Basic usage
init?(number: String)
- initializes correctly with a positive number comprised of one or two digits.Allowed numbers: 00, 01…09, 0…99.
Additional validation rules
You can use
init?(number: String, validationRules: Set<JerseyNumberValidationRule>)
to restrict valid numbers.JerseyNumberValidationRule
.only0to5
- returnsnil
ifnumber
contains digits in range of6...9
in any place.doubleZeroNotAllowed
- returnsnil
ifnumber
is"00"
.noLeadingZeros
- returnsnil
for values like 01…09Utility methods
copy(usingValidationRules rules: Set<JerseyNumberValidationRule>) -> BasketballJerseyNumber?
- makes a copy by following all provided rules.follows(rules: Set<JerseyNumberValidationRule>) -> Bool
- verifies the number against a set of provided rules.Protocol conformance
Conforms to
Hashable
andCustomStringConvertible
.