serializr
    Preparing search index...

    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.

      Parameters

      • modelSchema: ClazzOrModelSchema<any>

        to be used to (de)serialize the object

      • OptionaladditionalArgs: AdditionalPropArgs

        optional object that contains beforeDeserialize and/or afterDeserialize handlers

      Returns PropSchema

      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',
      },
      })