                 return counter
             case .timer(let period):
                 let timeSinceEpoch = time.timeIntervalSince1970
-                guard Generator.isValidTime(timeSinceEpoch) else {
-                    throw Error.invalidTime
-                }
-                guard Generator.isValidPeriod(period) else {
-                    throw Error.invalidPeriod
-                }
+                try Generator.validateTime(timeSinceEpoch)
+                try Generator.validatePeriod(period)
                 return UInt64(timeSinceEpoch / period)
             }
         }

    /// - throws: A `Generator.Error` if a valid password cannot be generated for the given time.
    /// - returns: The generated password, or throws an error if a password could not be generated.
    public func password(at time: Date) throws -> String {
        guard Generator.isValidDigits(digits) else {
            throw Error.invalidDigits
        }

        let counter = try factor.counterValue(at: time)
        // Ensure the counter value is big-endian

private extension Generator {
    // MARK: Validation

    static func validateDigits(_ digits: Int) throws {
        guard isValidDigits(digits) else {
            throw Error.invalidDigits
        }
    }

    static func isValidDigits(_ digits: Int) -> Bool {
        // https://tools.ietf.org/html/rfc4226#section-5.3 states "Implementations MUST extract a
        // 6-digit code at a minimum and possibly 7 and 8-digit codes."
