The root JSON schema of the entire form (N.B. rootSchema can also be a piece of the actual root
JSON schema, provided that has a JSON schema structure. Like for instance object
type, or oneOf
, and so on)
Optional
schema: anyThe schema for which the score is being calculated
The form data associated with the schema, used to calculate the score
Generated using TypeDoc
Recursive function that calculates the score of a
formData
against the givenschema
. The computation is fairly simple. Initially the total score is 0. Whenschema.properties
object exists, then all thekey/value
pairs within the object are processed as follows after obtaining the formValue fromformData
using thekey
:value
contains aoneOf
and there is a formValue, then score based on the index returned from callinggetClosestMatchingOption()
of that oneOf.value
is 'object',calculateIndexScore()
is called recursively with the formValue and thevalue
itself as the sub-schema, and the score is added to the total.value
matches the guessed-type of theformValue
, the score is incremented by 1, UNLESS the value has adefault
orconst
. In those case, if thedefault
orconst
and theformValue
match, the score is incremented by another 1 otherwise it is decremented by 1.Adapted from https://github.com/rjsf-team/react-jsonschema-form/blob/b8f700a1cd2b9b8d7f67040e334836d236b325a4/packages/utils/src/schema/getClosestMatchingOption.ts#L50