DValidate.ValidateFormat (d_validate v1.1.0)

Summary

Functions

Validates if a value matches the given regex pattern.

Functions

Link to this function

call(value, regex)

Validates if a value matches the given regex pattern.

Examples

iex> DValidate.ValidateFormat.call("asabca123", ~r/^\w+$/)
{:ok}

iex> DValidate.ValidateFormat.call("abc 123", ~r/^[\w\s]+$/)
{:ok}

iex> DValidate.ValidateFormat.call("abc@123", ~r/^\w+$/)
{:error, :field_name, "has an invalid format"}