You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: This page explains the inner workings of the library and is meant for engineers who want to contribute to the library.
JSON to schema
The jsonToSchema() function is the main function to convert a JSON object to the validation schema.
It will first run through generateFieldConfigs() which iterates through each field and call the corresponding field config generator based on the fieldType. Each field config generator will return the formatted yup schema and validation config of the field.
Then it runs through parseWhenKeys() which looks for conditional validation rules (when condition) and generate a yup schema based on the source field. This yup schema will be used in mapRules() to generate the actual conditional validation schema.
Next it runs through mapRules() which parses each validation config and generates the Yup schema rules accordingly. This function also assigns custom validation to the field.
Once this is done, a Yup validation schema is returned.