Skip to content

Evaluate runtime type validation libraries #25

@eaton

Description

@eaton

Currently we’re using a variety of jank methods to validate and transform data structures, particularly:

  • Option objects for Spider, Worker, Project, EnqueueUrls, and similar classes that operate on complex config
  • Storage entities’ creation data, and JSON-compatible serialization forms
  • Optional bags of data added to storage entities by project-specific code (i.e., a “content” struct added to some “resource” entities)

Our current half-baked approaches include:

  • Weak typechecks like isVerticeData
  • Ad-hoc custom validation (see various entity constructors)
  • Ad-hoc use of the ‘is’ library
  • Ad hoc use of class transformer functions during hydration/dehydration

We want something that can validate the structures of large, extensible structures; use the same definitions to check/downcast/coerce/assert, and spit out type definitions in addition to validator objects. The coercion case in particular is important; in some situations we support unserializable types and need a transform step, or support option aliases that need mapping before they’re used to instantiate things,

candidates atm include joi, ow, and superstruct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions