diff --git a/Sources/DiscogsService/Internal/Validation Rules/NotEmptyValidationRule.swift b/Sources/DiscogsService/Internal/Validation Rules/NotEmptyValidationRule.swift index c27491872..7b464f291 100644 --- a/Sources/DiscogsService/Internal/Validation Rules/NotEmptyValidationRule.swift +++ b/Sources/DiscogsService/Internal/Validation Rules/NotEmptyValidationRule.swift @@ -29,6 +29,17 @@ struct NotEmptyValidationRule: InputValidationRule { } +// MARK: - Definitions + +extension InputValidationRule where Self == NotEmptyValidationRule { + + // MARK: Constants + + /// A validation rule that checks whether an input is empty or not. + static var notEmpty: Self { .init() } + +} + // MARK: - Helpers private extension NotEmptyValidationRule { @@ -54,10 +65,3 @@ private extension NotEmptyValidationRule { } } - -// MARK: - Constants - -extension InputValidationRule where Self == NotEmptyValidationRule { - /// A validation rule that checks whether an input is empty or not. - static var notEmpty: Self { .init() } -} diff --git a/Sources/DiscogsService/Internal/Validation Rules/NotNilValidationRule.swift b/Sources/DiscogsService/Internal/Validation Rules/NotNilValidationRule.swift index 1b9472e0d..1bac4efe7 100644 --- a/Sources/DiscogsService/Internal/Validation Rules/NotNilValidationRule.swift +++ b/Sources/DiscogsService/Internal/Validation Rules/NotNilValidationRule.swift @@ -29,6 +29,17 @@ struct NotNilValidationRule: InputValidationRule { } +// MARK: - Definitions + +extension InputValidationRule where Self == NotNilValidationRule { + + // MARK: Constants + + /// A validation rule that checks whether an input is nil or not. + static var notNil: Self { .init() } + +} + // MARK: - Helpers private extension NotNilValidationRule { @@ -43,7 +54,7 @@ private extension NotNilValidationRule { /// - Returns: A flag that indicates whether a given input has been validated or not. /// - Throws: An error of type ``InputValidatorError`` in case the validation failed. func validate(input: String?) throws -> Bool { - guard let input else { + guard input != nil else { throw InputValidationError.inputIsNil } @@ -51,10 +62,3 @@ private extension NotNilValidationRule { } } - -// MARK: - Constants - -extension InputValidationRule where Self == NotNilValidationRule { - /// A validation rule that checks whether an input is nil or not. - static var notNil: Self { .init() } -}