Implemented the NotNilValidationRule type in the library target.

This commit is contained in:
2025-10-12 13:58:06 +02:00
parent 630f8a03f7
commit 2677bd8de5
2 changed files with 85 additions and 0 deletions
@@ -17,7 +17,32 @@ struct NotEmptyValidationRule: InputValidationRule {
// MARK: Functions
#if swift(>=6.0)
func validate(_ input: String?) throws(InputValidationError) -> Bool {
try validate(input: input)
}
#else
func validate(_ input: String?) throws -> Bool {
try validate(input: input)
}
#endif
}
// MARK: - Helpers
private extension NotEmptyValidationRule {
// MARK: Functions
/// Validates a given input.
///
/// > note: This helper function would not be necessary when support for *Swift 5.10* is discontinued.
///
/// - Parameter input: An input to be validated.
/// - 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 {
return false
}