@rjsf/utils
Version:
Utility functions for @rjsf/core
15 lines (14 loc) • 1.5 kB
TypeScript
import { Experimental_CustomMergeAllOf, FormContextType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types.js';
/** Helper that acts like lodash's `get` but additionally retrieves `$ref`s as needed to get the path for schemas
* containing potentially nested `$ref`s.
*
* @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 current node within the JSON schema recursion
* @param path - The keys in the path to the desired field
* @param defaultValue - The value to return if a value is not found for the `pathList` path
* @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
* @returns - The inner schema from the `schema` for the given `path` or the `defaultValue` if not found
*/
export default function getFromSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, rootSchema: S, schema: S, path: string | string[], defaultValue: T, experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>): T;
export default function getFromSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, rootSchema: S, schema: S, path: string | string[], defaultValue: S, experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>): S;