Swiftpack.co - validationapp/swift-sdk as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
validationapp/swift-sdk
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.

Installation:

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

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

Usage:

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")
}

GitHub

link
Stars: 2
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

Update to Doubles
28 weeks ago

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