getto-systems/elm-field/2.0.0

Getto.Field.Present

search field utilities - present

name_ = Form.prop .name (\v m -> { m | name = v })


model =
  { name = "name" |> Present.init signature "John"
  }


view =
  { name = model |> ( name_ |> Present.single Present.string )
  {-
    ( "name"
    , { field = model.name
      , prop  = name_
      }
    , { isPresent = True -- model.name |> Present.string
      }
    )
  -}
  }

Definition

type alias Model form opts =
( String, form, { opts | isPresent : Bool } )

field name, form and isPresent

type alias Single form opts a =
Model (Model form Attribute a) opts

single value model

type alias Between form opts a =
Model (Between form Attribute a) opts

gteq-lteq value model

type alias Field a =
Model Attribute a

no-attribute Field

type alias Prop form a =
Prop form Attribute a

Prop for no-attribute Field

type alias Presenter attr a =
Model attr a -> Bool

presence method

Construction

init : String -> value -> String -> Field value

construct Field

"name" |> Present.init signature ""
Presenter attr a
-> Prop form attr a
-> form
-> Model (Model form attr a) {}

construct Single

form |> ( name_ |> Present.single Present.string )
{ gteq : model -> Model (Model form attr a) opts
, lteq : model -> Model (Model form attr a) opts
}
-> String
-> model
-> Model (Between form attr a) {}

construct Between

form |>
  ( "age" |> Present.between
    { gteq = age_gteq_ |> Present.single Present.string
    , lteq = age_lteq_ |> Present.single Present.string
    }
  )

Presenters

string : Presenter attr String

string is not empty

set : Presenter attr (Set a)

set is not empty

present : (a -> Bool) -> Presenter attr a

field value is present