Message
Form <Message> displays error state for a field or set of fields. They
can be rendered anywhere under a <Form> and styled to suit your application.
Overview
<Message>s like <Field>s associate and subscribe to paths with the form data.
Following the api for HTML <label> the for prop is used instead of name.
Messages only render when there are errors.
Messages can be configured to display one, or all errors pertaining to a field
Messages are also not limited to a single field:
React formal is unopinionated about how errors should be styled. You can easily add your own styles to the Message or create a wrapper component for your application.
API
import Form from 'react-formal';const Message = Form.MessageRepresents a Form validation error message. Only renders when the
value that it is for is invalid.
children
A function that maps an array of message strings and returns a renderable string or ReactElement.
<Message> {errors => errors.join(', ')}</Message>(errors: any[], msgProps: any) => (
<span {...msgProps}>{errors.join(', ')}</span>
)className
errors
extract
Map the passed in message object for the field to a string to display
(error: any) => error.message || errorfilter
uniq