Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate runtime type validation libraries #25

Open
eaton opened this issue Nov 27, 2022 · 0 comments
Open

Evaluate runtime type validation libraries #25

eaton opened this issue Nov 27, 2022 · 0 comments

Comments

@eaton
Copy link
Contributor

eaton commented Nov 27, 2022

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.

@eaton eaton added this to Spidergram Nov 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant