Docs shows the prop signature using a function that takes a parameter and returns the schema.

But in my case nothing was passed into the props.

Use a Formik component with the validationSchema prop set to a function that takes in the prop as a parameter.
The prop should be filled with information related to the formik instance, so we can dynamically create a validationSchema based on filled in information (in my case postal codes change depending on selected country)
Simply pass the instance on into the function.
CodeSandbox Link:
Hi @elertan,
I don't believe this is an actual bug, but just a slight misinterpretation of the docs. In the documentation there's two different ways of using Formik, one is the _HoC way_ and another is the _render prop component_ way. You seem to be using the <Formik /> component way, which specifies the following in the docs:

Note down here there's two references for the validationSchema in the docs

So the props are only passed to the validation schema if you're using the HoC way.
Also: the props that are specified by the docs are not the formik bag props (such as the values, errors, etc.), but these are the props that you pass to the component (in this case the HoC). I hope I answered your questions!
Thanks @inooid! It's still a bit confusing seeing 2 docs right next to each other, but it definitely makes sense now.
Why can't we get props or formikBag in Formik's validationSchema like we do with withFormik?
well in fact you can here under the code
.
.
handleSubmit(values, { props, resetForm, setErrors, setSubmitting }) {
// let's suppose that we do a server validtion call
props.initiateLogin();
props.login(values);
setSubmitting(false);
},
validationSchema(props){
return object().shape({
username: string().required(USERNAME_REQUIRED),
password: string()
.min(3, PASSWORD_MIN_LENGTH_ERROR)
.required(PASSWORD_REQUIRED)
})
}
Why this isn't specified on the doc? (did I miss something?)
Would love to see a real world example.
I found a way without passing with withFormik hoc:
<Formik
...
validationSchema={() => validationSchema(this.props)}
/>
Most helpful comment
Thanks @inooid! It's still a bit confusing seeing 2 docs right next to each other, but it definitely makes sense now.