getto-systems / elm-field / 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 : Basics.Bool } 
)

field name, form and isPresent


type alias Single form opts a =
Model (Getto.Field.Form.Model form Attribute a) opts

single value model


type alias Between form opts a =
Model (Getto.Field.Form.Between form Attribute a) opts

gteq-lteq value model


type alias Field a =
Getto.Field.Model Attribute a

no-attribute Field


type alias Prop form a =
Getto.Field.Form.Prop form Attribute a

Prop for no-attribute Field


type alias Presenter attr a =
Getto.Field.Model attr a -> Basics.Bool

presence method

Construction

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

construct Field

"name" |> Present.init signature ""

single : Presenter attr a -> Getto.Field.Form.Prop form attr a -> form -> Model (Getto.Field.Form.Model form attr a) {}

construct Single

form |> ( name_ |> Present.single Present.string )

between : { gteq : model -> Model (Getto.Field.Form.Model form attr a) opts, lteq : model -> Model (Getto.Field.Form.Model form attr a) opts } -> String -> model -> Model (Getto.Field.Form.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 -> Basics.Bool) -> Presenter attr a

field value is present