Skip to content

Nested Schemas throw an error when calling getObjectSchema ("the parent SimpleSchema instance also tries to define ...") #504

@MaxTwentythree

Description

@MaxTwentythree

Hi,

I have nested schemas:

const simplSchema = new SimpleSchema({
  id: {type: String},
  type: {type: String},
  formField: {type: formFieldSchema},
  orderKey: {type: Number, optional: true},
});

const formFieldSchema = new SimpleSchema({
  id: {type: String},
  type: {type: String},
  label: {type: String, optional: true},
  placeholder: {type: String, optional: true},
  ...
  options: {type: formFieldOptionsSchema, optional: true},
});

const formFieldOptionsSchema = new SimpleSchema({
  textStyle: {type: textOptionsSchema, optional: true},
  button: {type: buttonOptionsSchema, optional: true},
  number: {type: numberOptionsSchema, optional: true},
  select: {type: selectOptionsSchema, optional: true},
});

etc.

When calling getObjectSchema('formField') on the upper schema, I receive this error:

Error: The type for "options" is set to a SimpleSchema instance that defines "options.textStyle", but the parent SimpleSchema instance also tries to define "options.textStyle"

What is this error, why is it thrown (it seems not correct) and how can I fix that? Am I doing sth wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions