yesod-like form builder for purescript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
src
test
.gitignore
README.md
bower.json
package.json

README.md

WForm

What this is

  • a spin-off of @parsonsmatt / ql-purs implementation of WForm
  • specific to halogen
  • specific to bootstrap form styles

What it should be

  • a generic forms library for purescript
    • not specific to halogen
    • not specific to any css style framework

example usage

renderView Registration st =
    H.div_ $ errs st.errors :
      -- The 3rd field (_name, _bio, etc) are the lens accessors to the form values
      F.renderForm st.registration Register do
        void $ F.textField     "name"     "User name"    _name         F.nonBlank
        void $ F.textFieldOpt  "bio"      "Bio"          _bio          F.optional
        void $ F.emailField    "email"    "Email"        _email        F.emailValidator
        void $ F.passwordField "password" "Password"     _password     validPassword
        F.passwordField        "confirm"  "Confirmation" _confirmation validConfirmation
      where
        validPassword str
            | Str.length str < 6 = Left "Password must be at least 6 characters"
            | otherwise          = Right str
        validConfirmation p
            | p == st ^. stRegistration <<< _password = Right p
            | otherwise = Left "Password must match confirmation"

Full example here