Skip to content

Undocumented type "*" should be avoided #19

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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