Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. validateSchema = (values: Object) => {
  2. try {
  3. this.props.validationSchema && this.props.validationSchema.validateSync(values, {abortEarly: false});
  4. return {};
  5. } catch (e) {
  6. return e.inner.reduce((errors, error) => {
  7. return setIn(errors, error.path, error.message);
  8. }, {});
  9. }
  10. };
  11.  
  12. render() {
  13. const {initialValues, onSubmit, validateOnBlur, subscription, render, validationSchema, ...props} = this.props;
  14. const validate = validationSchema ? this.validateSchema : undefined;
  15.  
  16. return (
  17. <FinalForm
  18. initialValues={initialValues}
  19. onSubmit={onSubmit}
  20. validate={validate}
  21. validateOnBlur={validateOnBlur}
  22. subscription={subscription}
  23. render={render}
  24. {...props}
  25. />
  26. );
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement