Skip to content

jakub-zawislak/formex_vex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Formex Vex

Library that integrates Vex validator with Formex.

Installation

def deps do
  [{:formex_vex, "~> 0.1.0"}]
end

config/config.exs

config :formex,
  validator: Formex.Validator.Vex

See Formex.Validator docs for more info

Usage

  def build_form(form) do
    form
    |> add(:name, :text_input, validation: [presence: :true, length: [in: 10..150]])
    |> add(:content, :textarea, validation: [presence: [message: "can't be blank"]])
    |> add(:slug, :text_input, validation: fn (text) ->
      if !Repo.get_by(Article, slug: text) do
        :ok
      else
        {:error, "already used!!1"}
      end
    end)
    # ...
  end

See Vex documentation for more options

About

Vex validator adapter for Formex

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages