Skip to content
This repository was archived by the owner on Nov 16, 2020. It is now read-only.

Commit 870fe99

Browse files
committed
Replace CountValidator messages as suggested in review
1 parent c5a34b3 commit 870fe99

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Sources/Validation/Validators/CountValidator.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ fileprivate struct CountValidator<T>: ValidatorType where T: Collection {
6868
func validate(_ data: T) throws {
6969
if let min = self.min {
7070
guard data.count >= min else {
71-
throw BasicValidationError("is shorter than \(elementDescription(count: min))")
71+
throw BasicValidationError("is less than required minimum of \(elementDescription(count: min))")
7272
}
7373
}
7474

7575
if let max = self.max {
7676
guard data.count <= max else {
77-
throw BasicValidationError("is longer than \(elementDescription(count: max))")
77+
throw BasicValidationError("is greater than required maximum of \(elementDescription(count: max))")
7878
}
7979
}
8080
}

Tests/ValidationTests/ValidationTests.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ class ValidationTests: XCTestCase {
7272
try validator.validate("123")
7373
try validator.validate("123456")
7474
XCTAssertThrowsError(try validator.validate("")) { error in
75-
XCTAssertEqual((error as? ValidationError)?.reason, "data is shorter than 1 character")
75+
XCTAssertEqual((error as? ValidationError)?.reason, "data is less than required minimum of 1 character")
7676
}
7777
XCTAssertThrowsError(try validator.validate("1234567")) { error in
78-
XCTAssertEqual((error as? ValidationError)?.reason, "data is longer than 6 characters")
78+
XCTAssertEqual((error as? ValidationError)?.reason, "data is greater than required maximum of 6 characters")
7979
}
8080
}
8181

@@ -85,10 +85,10 @@ class ValidationTests: XCTestCase {
8585
try validator.validate([1, 2, 3])
8686
try validator.validate([1, 2, 3, 4, 5, 6])
8787
XCTAssertThrowsError(try validator.validate([])) { error in
88-
XCTAssertEqual((error as? ValidationError)?.reason, "data is shorter than 1 item")
88+
XCTAssertEqual((error as? ValidationError)?.reason, "data is less than required minimum of 1 item")
8989
}
9090
XCTAssertThrowsError(try validator.validate([1, 2, 3, 4, 5, 6, 7])) { error in
91-
XCTAssertEqual((error as? ValidationError)?.reason, "data is longer than 6 items")
91+
XCTAssertEqual((error as? ValidationError)?.reason, "data is greater than required maximum of 6 items")
9292
}
9393
}
9494

0 commit comments

Comments
 (0)