UNPKG

react-formal

Version:

Classy HTML form management for React

42 lines (41 loc) 1.45 kB
import PropTypes from 'prop-types'; import React from 'react'; import { Errors } from './types'; export interface MessageProps { errors?: Errors; for: string | string[]; className?: string; filter?: (item: any, i?: number, list?: any[]) => boolean; extract?: (errors: any, props: any) => any; children?: (errors: any[], props: any) => React.ReactNode; } /** * Represents a Form validation error message. Only renders when the * value that it is `for` is invalid. * * @alias FormMessage * @memberof Form */ declare function Message({ errors: propsErrors, for: names, className, filter, extract, children, ...props }: MessageProps): JSX.Element | null; declare namespace Message { var propTypes: { for: PropTypes.Requireable<NonNullable<string | (string | null | undefined)[] | null | undefined>>; /** * A function that maps an array of message strings * and returns a renderable string or ReactElement. * * ```jsx static * <Message> * {errors => errors.join(', ')} * </Message> * ``` */ children: PropTypes.Requireable<(...args: any[]) => any>; /** * Map the passed in message object for the field to a string to display */ extract: PropTypes.Requireable<(...args: any[]) => any>; filter: PropTypes.Requireable<(...args: any[]) => any>; }; } export default Message;