Short v0.0.1 Short.Code View Source

A Short Code.

This module defined a Short Code and the main functions for working with Short Codes.

Link to this section Summary

Functions

Generates valid code

Returns a new Wrapped code

Check if the code is valid to be used in an URI

Link to this section Types

Link to this type t() View Source
t() :: %Short.Code{__code: String.t}

Link to this section Functions

Link to this function generate(length \\ 0) View Source
generate(integer) :: Short.Code.t

Generates valid code.

By default, the code will be of default_code_length length. Short allows this default code length to be overriden through the Mix configuration of the :short application. For example, to override the length, the following config can be specified:

config :short, :code_length, 7

Returns a new Wrapped code.

Examples

iex> Short.Code.new("abc")
%Short.Code{__code: "abc"}

iex> Short.Code.new("?!&")
%Short.Code{__code: "?!&"}

Check if the code is valid to be used in an URI.

Examples

iex> Short.Code.valid?("abc")
true

iex> Short.Code.valid?("?!&")
false