Skip to content

MailFaker is a Swift Package that can be used to generate random names and email addresses.

License

Notifications You must be signed in to change notification settings

AiondaDotCom/MailFaker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

MailFaker is currently only available via Swift Package Manager (SPM). It is not planned to implement support for CocoaPods or Carthage - but feel free to make a pull request.

// Add MailFaker to your Package.swift:

import PackageDescription

let package = Package(
    // ...
    dependencies: [
        .package(url: "https://github.com/AiondaDotCom/MailFaker", from: "1.0.0"),
    ]
    // ...
)

Xcode >=11: File -> Swift Packages -> Add Package Dependency...

Usage

// Add MailFaker to your class
import MailFaker

// Create an instance of MailFaker
let mailFaker = MailFaker()

// Generate random names and emails
mailFaker.firstName()       // => A random first name
mailFaker.lastName()        // => A random last name
mailFaker.fullName()        // => A random full name
mailFaker.localPart()       // => A random local-part of an email address
mailFaker.domainPart()      // => A random domain-part of an email address
mailFaker.fullAddress()     // => A random email address

Examples

The following code examples should only give a short overview of the features of MailFaker. A detailed documentation is shown in Xcode.

Initialize MailFaker

let mailFaker = MailFaker() 
// => language code of the current locale (e.g. "de") will be used.

let mailFaker = MailFaker(withExplicitLocale: "fr") 
// => language code "fr" will be used.

// Fallback is always "en" and is used if the given language code is not supported.

Generate first names

mailFaker.firstName(.female)    // e.g. Manuela
mailFaker.firstName(.male)      // e.g. Benedikt
mailFaker.firstName()           // e.g. Peter

// mailFaker.firstName() is equal to mailFaker.firstName(.random)

Generate last names

mailFaker.lastName()    // e.g. Müller

Generate full names

mailFaker.fullName(.female)     // e.g. Lisa Müller
mailFaker.fullName(.male)       // e.g. Markus Urban
mailFaker.fullName()            // e.g. Sabine Meier 

// mailFaker.fullName() is equal to mailFaker.fullName(.random)

Generate local-parts of email addresses

mailFaker.localPart(.female)     // e.g. reitze_anabel-3377
mailFaker.localPart(.male)       // e.g. danneberg.mark_1823
mailFaker.localPart()            // e.g. 3714.patrick-gabius 

// mailFaker.localPart() is equal to mailFaker.localPart(.random)

Generate domain-parts of email addresses

mailFaker.domainPart()    // e.g. dolor.fr

Generate full email addresses

mailFaker.fullAddress(.female)     // e.g. 9792.krippner-nisa@lorem.de
mailFaker.fullAddress(.male)       // e.g. tiago_dies-8420@molestiae.americanexpress
mailFaker.fullAddress()            // e.g. 2245.schirmer-michaela@dicta.net

// mailFaker.fullAddress() is equal to mailFaker.fullAddress(.random)

Documentation

All code is fully documented and uses the Apple Markup Formatting Reference.

Example of documentation

License

MailFaker is available under the MIT license. See LICENSE.md for more info.

This project was inspired and contains data from: faker.js.

About

MailFaker is a Swift Package that can be used to generate random names and email addresses.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages