![]() Open your liveview file lib/form_validator_web/live/page_live. |> validate_format( :password, # $%^&*_0-9]/, message: "at least one digit or punctuation character") |> validate_format( :password, ~r//, message: "at least one upper case character") Best Sellers Programming Phoenix LiveView by Bruce Tate and Sophie DeBenedetto From Ruby to Elixir by Stephen Bussey Programming Ruby 3.2 5e Noel Rappin Agile. |> validate_format( :password, ~r//, message: "at least one lower case character") |> validate_length( :password, min: 6, max: 80) |> validate_length( :username, min: 5, max: 30)Įnd defp validate_password(changeset) do changeset |> validate_format( :username, ~r/^*$/, message: "Please use letters and numbers without space(only characters allowed _. |> validate_format( :email, ~r/^+$/, message: "must have the sign and no spaces")Įnd defp validate_username(changeset) do changeset |> validate_required()Įnd defp validate_email(changeset) do changeset $ mix Accounts User users email:string username:string password:stringĪdd your validation to your users schema changeset, open lib/form_validator/accounts/user.ex and add the following: Let’s create a context, by going to the command line and typing the following command: |> render_change() =~ "at least one digit or punctuation character" end end Phoenix Context: To that newly created file test/form_validator_web/live/page_live_test.exs add the following tests:ĭefmodule FormValidatorWeb.PageLiveTest do use FormValidatorWeb.ConnCase import Phoenix.LiveViewTest %) By signing up, you agree to our Terms, Data Policy and Cookies Policy.Īdd the following folder under test/form_validator_web:Īdd the following file to that newly created folder: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |