Skip to content

Undocumented type "*" should be avoided #19

@t2ym

Description

@t2ym

Undocumented type "*" should be avoided

Backgrounds

  • "*" type copies the reference to the value without validation
  • Even a function can be assigned

Workarounds

  • Use combination of other types such as "null|boolean|number|string" instead
  • "object" type just copies the reference to the original object without validation

Notes

  • If initProperties is created via JSON.parse(), the risk of using the "*" type is largely mitigated.

Other Mitigation Candidates

  • Defining specific types is the best practice, considering the objective of schema definitions.
  • Introducing a new type or an option to clone untyped objects via JSON.parse(JSON.stringify(value)) might be effective to mitigate unexpected corruption of the object in validation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions