This module defines some of the tools to work with fields
withLabel : String -> Field form value state msg error ctx fieldCtx view -> Field form value state msg error ctx fieldCtx view
Add a label to your field. The field is put inside a label tag.
withPlaceholder : String -> Field form value state msg error ctx fieldCtx view -> Field form value state msg error ctx fieldCtx view
Add a placeholder value to a field.
withDescription : String -> Field form value state msg error ctx fieldCtx view -> Field form value state msg error ctx fieldCtx view
Add a short description under a field
a -> Result hint ()
Hint
ctx -> form -> Result hint ()
Global Hint
withHints : List (Hint hint value) -> Field form value state msg hint ctx fieldCtx view -> Field form value state msg hint ctx fieldCtx view
Add hints to a field. When the field is updated all the hints will be tested and displayed if they don't pass.
withGlobalHints : List (GlobalHint ctx hint form) -> Field form value state msg hint ctx fieldCtx view -> Field form value state msg hint ctx fieldCtx view
Add a global hint
notEmpty : hint -> String -> Result hint ()
Fails in case the string is empty or whitespace only
isTrue : hint -> Basics.Bool -> Result hint ()
Fails if false
isDefined : hint -> Maybe a -> Result hint ()
Fails if the Maybe does not contain a value
isEmail : hint -> String -> Result hint ()
Will use a regex to check if a string is in an email shape
{ view : fieldCtx -> ViewConfig value state hint -> view
, state : Value value state
, update : fieldCtx -> msg -> Value value state -> Value value state
, hints : List hint
, label : Maybe String
, placeholder : Maybe String
, description : Maybe String
, getContext : ctx -> fieldCtx
, hinting : List (Hint hint value)
, globalHinting : List (GlobalHint ctx hint form)
}
The internal field type.
These messages can be used by the form system
a -> Result hint b
Parse a field to another value.
{ state | value : value }
Every field state needs to have a value
{ state : Value value state
, hints : List hint
, label : Maybe String
, placeholder : Maybe String
, description : Maybe String
}
The record given to a field view function