Function object

  • object indicates that this property contains an object that needs to be (de)serialized using its own model schema.

    N.B. mind issues with circular dependencies when importing model schema's from other files! The module resolve algorithm might expose classes before createModelSchema is executed for the target class.

    Example

    class SubTask {}
    class Todo {}

    createModelSchema(SubTask, {
    title: true,
    })
    createModelSchema(Todo, {
    title: true,
    subTask: object(SubTask),
    })

    const todo = deserialize(Todo, {
    title: 'Task',
    subTask: {
    title: 'Sub task',
    },
    })

    Parameters

    • modelSchema: ClazzOrModelSchema<any>

      to be used to (de)serialize the object

    • Optional additionalArgs: AdditionalPropArgs

      optional object that contains beforeDeserialize and/or afterDeserialize handlers

    Returns PropSchema

Generated using TypeDoc