Skip to content

Commit a728a0e

Browse files
committed
Remove extra spaces
1 parent d30e33c commit a728a0e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Customs/WooShippingCustomsItemViewModel.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private extension WooShippingCustomsItemViewModel {
144144
/// Follows validation logic from `woocommerce-shipping/client/utils/customs.ts`
145145
enum HSTariffNumberValidator {
146146
static let pattern = "^(\\d{1,2}\\.?){3,6}$"
147-
147+
148148
/// Check if the HS Tariff Number is valid.
149149
/// It should be a string of 6 to 12 digits, with optional dots in between every 2 digits.
150150
/// - Parameter tariffNumber: The tariff number string.
@@ -169,4 +169,12 @@ enum HSTariffNumberValidator {
169169
let count = digitsOnly.count
170170
return count >= 6 && count <= 12
171171
}
172+
173+
/// Sanitize the HS Tariff Number
174+
/// Remove all non-digit characters
175+
/// - Parameter tariffNumber: The tariff number string.
176+
/// - Returns: Tariff string without non-digit characters
177+
static func sanitize(_ tariffNumber: String) -> String {
178+
return tariffNumber.components(separatedBy: CharacterSet.decimalDigits.inverted).joined()
179+
}
172180
}

0 commit comments

Comments
 (0)