@rjsf/utils
Version:
Utility functions for @rjsf/core
20 lines (19 loc) • 1.66 kB
TypeScript
import { Experimental_CustomMergeAllOf, FormContextType, FoundFieldType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types.js';
/** Unique schema that represents no schema was found, exported for testing purposes */
export declare const NOT_FOUND_SCHEMA: {
title: string;
};
/** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified
* `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf
* field is in the `required` list for its parent and if so, it is marked as required on return.
*
* @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
* @param rootSchema - The root schema that will be forwarded to all the APIs
* @param schema - The node within the JSON schema in which to search
* @param path - The keys in the path to the desired field
* @param [formData={}] - The form data that is used to determine which anyOf/oneOf option to descend
* @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
* @returns - An object that contains the field and its required state. If no field can be found then
* `{ field: undefined, isRequired: undefined }` is returned.
*/
export default function findFieldInSchema<T = undefined, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, rootSchema: S, schema: S, path: string | string[], formData?: T, experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>): FoundFieldType<S>;