Swiftpack.co -  Package - validationapp/swift-sdk
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A Swift SDK for the validation.app service
.package(url: "https://github.com/validationapp/swift-sdk.git", from: "0.0.3")

Swift EmailValidation

This package is a client for the https://validation.app API. It allows you to submit an email for validation and receive the response from the API in a typed fashion.

Note: You must first have an API key and tokens available from the https://validation.app platform.


To start using EmailValidation, in your Package.swift add the following

.package(url: "https://github.com/validationapp/swift-sdk.git", from: "0.0.1")


Initialize the EmailValidator:

let httpClient = HTTPClient(..)
let validator = EmailValidator(httpClient: httpClient, apiKey: "ADD_YOUR_API_KEY_HERE", eventLoop: eventLoop)

If you are in a Vapor app, you can do something like this:

extension Request {
    var emailValidator: EmailValidator {
        if self.application.environment == .testing {
            return MockEmailValidator(eventLoop: self.eventLoop)
        } else {
            return EmailValidatorAPI(
                httpClient: self.application.http.client.shared,
                apiKey: "ADD_YOUR_API_KEY_HERE",
                eventLoop: self.eventLoop

Once you have an EmailValidator object, you can call .validate(email: "email-goes-here") on it to get back a EmailValidationResponse object:

let response = try validator.validate(email: "email@email.com").wait()
XCTAssertEqual(response.data.request_email, "email@email.com") // True

If you have the EmailValidator installed as an extension in your Vapor app, you can use it in routes:

func myRoute(req: Request) throws -> EventLoopFuture<EmailValidationResponse> {
    req.emailValidator.validate(email: "email@email.com")

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco