import React from 'react'; import {Field, reduxForm} from '../../index'; const validationIsRequired = (value) => !value ? 'Field required.' : undefined; const validationMinLength = (minLength) => (value) => value && (value.length < minLength) ? `The minimum length of the value must be ${minLength}.` : undefined; const validate = (values) => { const errors: MapMessages = {}; errors.firstName = validationIsRequired(values.firstName); errors.lastName = validationIsRequired(values.lastName); return errors; }; const warn = (values) => { const warnings: MapMessages = {}; warnings.firstName = validationMinLength(2)(values.firstName); warnings.lastName = validationMinLength(2)(values.lastName); return warnings; }; const SyncValidation = (props) => { const {handleSubmit} = props; return (
); }; SyncValidation.displayName = 'InnerSyncValidation'; export default reduxForm({ form: 'example', validate, warn, })(SyncValidation);