request: setValidationEnabled
should [un]wrap the validator into an PartialValidator<T>
#191
Open
1 task done
Labels
Is there an existing issue or pull request for this?
Feature description
Right now, all validators have checks for whether or not they should run validations, as seen below:
shapeshift/src/validators/BaseValidator.ts
Lines 74 to 78 in e9a029a
This comes with a large performance impact, specially from those who desire to use the library without conditional validation. Also goes against Shapeshift's internal design of running the least amount of conditionals as possible.
Before we added conditional validation, Shapeshift was comfortably among the fastest libraries in our benchmarks.
Desired solution
A wrapper would solve the performance impact by making the validators always run the logic and constraints, where the
PartialValidator<T>
would exclusively only run the handler and never the constraints (with no extra checks, of course).For function (dynamic validation), we can also add a second class, or add a check in
PartialValidator<T>
, invalidating the last sentence in the previous paragraph.Unwrapping a
PartialValidator<T>
should give back the underlying, fully-checked validator.Alternatives considered
N/a.
Additional context
No response
The text was updated successfully, but these errors were encountered: