Module

Lumi.Components.Form.Validation

Package
purescript-lumi-components
Repository
lumihq/purescript-lumi-components

#Validator Source

type Validator result valid = result -> Either String valid

A Validator takes a possibly invalid form result and produces a valid result, or an error message.

#nonEmpty Source

nonEmpty :: String -> Validator String NonEmptyString

A Validator which verifies that an input string is non-empty.

#nonEmptyArray Source

nonEmptyArray :: forall a. String -> Validator (Array a) (NonEmptyArray a)

A Validator which verifies that an input array is non-empty.

#nonNull Source

nonNull :: forall a. String -> Validator (Maybe a) a

A Validator which verifies that an optional field is specified.

#mustEqual Source

mustEqual :: forall a. Eq a => a -> String -> Validator a a

A Validator which verifies that its input equals some value.

#mustBe Source

mustBe :: forall a. (a -> Boolean) -> String -> Validator a a

A Validator which verifies that its input fulfills a specified condition.

#validNumber Source

validNumber :: String -> Validator String Number

A Validator which verifies that its input can be parsed as a number.

#validInt Source

validInt :: String -> Validator String Int

A Validator which verifies that its input can be parsed as an integer.

#validDate Source

validDate :: String -> Validator String Date

A Validator which verifies that its input can be parsed as a date. Dates are of the format "YYYY-MM-DD".

#optional Source

optional :: forall a. Validator String a -> Validator String (Maybe a)

Modify a Validator to accept empty strings in addition to anything it already accepts. The empty string is mapped to Nothing, and any other valid input is mapped to Just the result of the original validator.

#Validated Source

data Validated a

The Validated type describes the state of a validated form field. This state may be used to modify the way this form field or its validation messages are displayed.

TODO: maybe convert this type to a record? Possible extensions to this type (as a record) could be a field valid :: Boolean to display an indicator that the field is valid, or a field validating :: Maybe (Canceler a) to control form fields with asynchronous validation.

Constructors

Instances

#_Validated Source

_Validated :: forall a b. Lens (Validated a) (Validated b) a b

Lens for viewing and modifying Validated values.

#_Fresh Source

_Fresh :: forall a. Prism' (Validated a) a

Prism for the Fresh constructor of Validated.

#_Modified Source

_Modified :: forall a. Prism' (Validated a) a

Prism for the Modified constructor of Validated.

#setFresh Source

setFresh :: forall value. Mapping ModifyValidated value value => value -> value

Sets all Validated fields in a record to Fresh, hiding all validation messages.

#setModified Source

setModified :: forall value. Mapping ModifyValidated value value => value -> value

Sets all Validated fields in a record to Modified, showing all validation messages.

#ModifyValidated Source

newtype ModifyValidated

Internal utility type for modifying the validated state of fields in records containing Validated values.

Constructors

Instances

#CanValidate Source

class CanValidate u v | u -> v where

Internal utility type class used to flatten repeated applications of Validated to a type.

Members

Instances

#validated Source

validated :: forall props unvalidated validated result result_. CanValidate unvalidated validated => Validator result_ result -> FormBuilder { readonly :: Boolean | props } unvalidated result_ -> FormBuilder { readonly :: Boolean | props } (Validated validated) result

Attach a validation function to a FormBuilder p u a, producing a new FormBuilder that takes a Validated u as form state and displays an error message if its form data is invalid.

This Validated data type describes a form field as either Fresh or Modified, so that validation messages are only displayed if the field is Modified.

#warn Source

warn :: forall props unvalidated validated result. CanValidate unvalidated validated => WarningValidator result -> FormBuilder { readonly :: Boolean | props } unvalidated result -> FormBuilder { readonly :: Boolean | props } (Validated validated) result

Attach a validation function to a FormBuilder p u a, producing a new FormBuilder that takes a Validated u as form state and displays a warning message if its form data triggers a warning, while still allowing the form to proceed.

Modules
JSS
Lumi.Components.Badge
Lumi.Components.Border
Lumi.Components.Breadcrumb
Lumi.Components.Button
Lumi.Components.ButtonGroup
Lumi.Components.Card
Lumi.Components.CardGrid
Lumi.Components.Color
Lumi.Components.Column
Lumi.Components.Details
Lumi.Components.Divider
Lumi.Components.DropdownButton
Lumi.Components.EditableTable
Lumi.Components.FetchCache
Lumi.Components.FixedPrecisionInput
Lumi.Components.Form
Lumi.Components.Form.Defaults
Lumi.Components.Form.Internal
Lumi.Components.Form.Table
Lumi.Components.Form.Validation
Lumi.Components.Icon
Lumi.Components.Images
Lumi.Components.Input
Lumi.Components.InputGroup
Lumi.Components.LabeledField
Lumi.Components.Layouts
Lumi.Components.Layouts.Centered
Lumi.Components.Layouts.OneColumnWithHeader
Lumi.Components.Layouts.Tabs
Lumi.Components.Link
Lumi.Components.List
Lumi.Components.Loader
Lumi.Components.Lockup
Lumi.Components.Modal
Lumi.Components.NativeSelect
Lumi.Components.Navigation
Lumi.Components.Orientation
Lumi.Components.Pagination
Lumi.Components.Pill
Lumi.Components.Progress
Lumi.Components.Responsive
Lumi.Components.Row
Lumi.Components.Select
Lumi.Components.Select.Backend
Lumi.Components.Size
Lumi.Components.Slider
Lumi.Components.Spacing
Lumi.Components.Status
Lumi.Components.StatusSlat
Lumi.Components.Styles
Lumi.Components.Svg
Lumi.Components.Tab
Lumi.Components.Table
Lumi.Components.Table.FilterDropdown
Lumi.Components.Text
Lumi.Components.Textarea
Lumi.Components.Toast
Lumi.Components.Tooltip
Lumi.Components.Upload
Lumi.Components.Utility.ReactRouter
Lumi.Components.Wizard
Lumi.Components.ZIndex