diff --git a/src/components/Form.js b/src/components/Form.js index 79215ffae8..d2f8b2a1bc 100644 --- a/src/components/Form.js +++ b/src/components/Form.js @@ -9,7 +9,9 @@ import { setState, getDefaultRegistry, } from "../utils"; -import validateFormData from "../validate"; +import { getValidator, validateFormData } from "../validate"; + +export { getValidator }; export default class Form extends Component { static defaultProps = { diff --git a/src/index.js b/src/index.js index ee2b982967..1c3d31edbf 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,5 @@ import Form from "./components/Form"; +import { getValidator } from "./components/Form"; +export { getValidator }; export default Form; diff --git a/src/validate.js b/src/validate.js index 1f72b8dcd3..ad239f0fef 100644 --- a/src/validate.js +++ b/src/validate.js @@ -142,6 +142,10 @@ function transformAjvErrors(errors = []) { }); } +function getValidator() { + return ajv; +} + /** * This function processes the formData with a user `validate` contributed * function, which receives the form data and an `errorHandler` object that @@ -176,3 +180,5 @@ export default function validateFormData( return { errors: newErrors, errorSchema: newErrorSchema }; } + +export { getValidator, validateFormData };