SmsUp.Otp.PinGenerator (sms_up v0.0.1) View Source
This module provides function to create some pin to be verified later after sms is sent.
Link to this section Summary
Functions
Generate a random pin number of the given length (min: 1, max: 10).
Link to this section Functions
Specs
Generate a random pin number of the given length (min: 1, max: 10).
Returns a pin of the given length as a string.
Examples
iex> SmsUp.Otp.PinGenerator.generate_pin()
{:ok, "012345"}
iex> SmsUp.Otp.PinGenerator.generate_pin(4)
{:ok, "0123"}
iex> SmsUp.Otp.PinGenerator.generate_pin(100)
{:ok, "0123456789"}
iex> SmsUp.Otp.PinGenerator.generate_pin(0)
{:error, "invalid size of 0, please use a positive integer"}
iex> SmsUp.Otp.PinGenerator.generate_pin(-6)
{:error, "invalid size of -6, please use a positive integer"}