MCPcopy Create free account
hub / github.com/eclipsesource/jsonforms / isObjectArrayWithNesting

Function isObjectArrayWithNesting

packages/core/src/testers/testers.ts:518–580  ·  view source on GitHub ↗
(
  uischema: UISchemaElement,
  schema: JsonSchema,
  context: TesterContext
)

Source from the content-addressed store, hash-verified

516};
517
518export const isObjectArrayWithNesting = (
519 uischema: UISchemaElement,
520 schema: JsonSchema,
521 context: TesterContext
522): boolean => {
523 if (!uiTypeIs('Control')(uischema, schema, context)) {
524 return false;
525 }
526 const schemaPath = (uischema as ControlElement).scope;
527 const resolvedSchema = resolveSchema(
528 schema,
529 schemaPath,
530 context?.rootSchema ?? schema
531 );
532 let objectDepth = 0;
533 if (resolvedSchema !== undefined && resolvedSchema.items !== undefined) {
534 // check if nested arrays
535 if (
536 traverse(
537 resolvedSchema.items,
538 (val) => {
539 if (val === schema) {
540 return false;
541 }
542 if (val.$ref !== undefined) {
543 return false;
544 }
545 if (val.anyOf || val.allOf) {
546 return true;
547 }
548 if (val.oneOf && !isOneOfEnumSchema(val)) {
549 return true;
550 }
551 if (hasType(val, 'object')) {
552 objectDepth++;
553 if (objectDepth === 2) {
554 return true;
555 }
556 }
557 if (hasType(val, 'array')) {
558 return true;
559 }
560 return false;
561 },
562 context?.rootSchema
563 )
564 ) {
565 return true;
566 }
567 // check if uischema options detail is set
568 if (uischema.options && uischema.options.detail) {
569 if (typeof uischema.options.detail === 'string') {
570 return uischema.options.detail.toUpperCase() !== 'DEFAULT';
571 } else if (
572 typeof uischema.options.detail === 'object' &&
573 uischema.options.detail.type
574 ) {
575 return true;

Callers 1

testers.test.tsFile · 0.90

Calls 5

resolveSchemaFunction · 0.90
isOneOfEnumSchemaFunction · 0.90
hasTypeFunction · 0.90
uiTypeIsFunction · 0.85
traverseFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…