Skip to content

Proposal: Memoization #254

Open
Open
@aigoncharov

Description

@aigoncharov

Proposal:
Add a flag to class-validator's config which enables memoization. When memoization is enabled, class validator keeps the result of last validation for each field and doesn't really run validation returning the result for the field right away. As to validating nested arrays, it keeps the results of last validation for each element.

Use case:
Using class-validator on a client side when validating form that have lots of elements. If form has 100 inputs, then validation upon entering a new symbol into any one of them could take lots of resources and be very frustrating. Memoization should significantly ease that pain.
Using class-validator on a client side is justified when we want to use the same DTO and validation for both: server and client.

Would you be willing to accept a PR with this functionality?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: discussionIssues discussing any topic.type: featureIssues related to new features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions