/* eslint react/no-multi-comp:0, no-console:0 */
import { createForm } from '../index';
import { regionStyle, errorStyle } from './styles';
const Email = {
props: {
form: Object,
},
render() {
const { getFieldProps, getFieldError, isFieldValidating } = this.form;
const errors = getFieldError('email');
return (
email validate onBlur && onChange
{errors ? errors.join(',') : null}
{isFieldValidating('email') ? 'validating' : null}
);
},
};
const User = {
props: {
form: Object,
},
render() {
const { getFieldProps, getFieldError, isFieldValidating } = this.form;
const errors = getFieldError('user');
return (
user validate on submit
{errors ? errors.join(',') : null}
{isFieldValidating('user') ? 'validating' : null}
);
},
};
const Form = {
props: {
form: Object,
},
methods: {
onSubmit(e) {
e.preventDefault();
this.form.validateFields((error, values) => {
if (!error) {
console.log('ok', values);
} else {
console.log('error', error, values);
}
});
},
},
render() {
const { form } = this;
return (
use validateTrigger config
);
},
};
export default createForm()(Form);