Mandrake v0.0.2 Mandrake.Validation

Mandrake validation functions.

Summary

Functions

Returns true if the given value is a valid amount

Returns always true

Returns true if the given value is a valid email

Returns true if the given value is a valid gender (m/M, f/F)

Returns true if the given value is a valid hex

Returns true if the given value is a valid html tag

Returns true if the given value is a valid ip address

Returns true if the given value is a valid name

Returns true if the given value is a valid number

Returns true if the given value is a valid password (letters, numbers, underscores, hyphens, 6 < password_length < 18)

Returns true if the given value is a valid phone number

Returns true if the given value is a valid slug

Returns a function that test the given regex

Returns a boolean indicating whether there was a match or not

Returns true if the given value is a valid url

Returns true if the given value is a valid username (letters, numbers, underscores, hyphens, 3 < username_length < 18)

Returns true if the given value is a valid year

Functions

amount(string)

Returns true if the given value is a valid amount.

Examples

iex>  Mandrake.Validation.amount("0")
true
iex>  Mandrake.Validation.amount("0.00")
true
iex>  Mandrake.Validation.amount("0,00")
true
anything(string)

Returns always true.

Examples

iex>  Mandrake.Validation.anything("foo")
true
email(string)

Returns true if the given value is a valid email.

Examples

iex>  Mandrake.Validation.email("foo@bar.com")
true
gender(string)

Returns true if the given value is a valid gender (m/M, f/F).

Examples

iex>  Mandrake.Validation.gender("m")
true
hex(string)

Returns true if the given value is a valid hex.

Examples

iex>  Mandrake.Validation.hex("#C0C0C0")
true
html(string)

Returns true if the given value is a valid html tag.

Examples

iex>  Mandrake.Validation.html("<a href='https://example.org'>My example link</a>")
true
ip_address(string)

Returns true if the given value is a valid ip address.

Examples

iex>  Mandrake.Validation.ip_address("127.0.0.1")
true
name(string)

Returns true if the given value is a valid name.

Examples

iex>  Mandrake.Validation.name("Matteo Basso")
true
iex>  Mandrake.Validation.name("Martin Luther King, Jr.")
true
number(string)

Returns true if the given value is a valid number.

Examples

iex>  Mandrake.Validation.number("535")
true
password(string)

Returns true if the given value is a valid password (letters, numbers, underscores, hyphens, 6 < password_length < 18).

Examples

iex>  Mandrake.Validation.password("Examplepassword")
true
phone_number(string)

Returns true if the given value is a valid phone number.

Examples

iex>  Mandrake.Validation.phone_number("(123) 456 7899")
true
iex>  Mandrake.Validation.phone_number("(123).456.7899")
true
iex>  Mandrake.Validation.phone_number("(123)-456-7899")
true
iex>  Mandrake.Validation.phone_number("123-456-7899")
true
iex>  Mandrake.Validation.phone_number("123 456 7899")
true
iex>  Mandrake.Validation.phone_number("1234567899")
true
slug(string)

Returns true if the given value is a valid slug.

Examples

iex>  Mandrake.Validation.slug("my-example-tytle")
true
test(regex)

Returns a function that test the given regex.

Examples

iex>  testFoo = Mandrake.Validation.test(~r/foo/)
...>  testFoo.("bar")
false
test(regex, string)

Returns a boolean indicating whether there was a match or not.

Examples

iex>  Mandrake.Validation.test(~r/foo/, "foo")
true
url(string)

Returns true if the given value is a valid url.

Examples

iex>  Mandrake.Validation.url("http://example.org/")
true
username(string)

Returns true if the given value is a valid username (letters, numbers, underscores, hyphens, 3 < username_length < 18).

Examples

iex>  Mandrake.Validation.username("mbasso")
true
year(string)

Returns true if the given value is a valid year.

Examples

iex>  Mandrake.Validation.year("2015")
true