Skip to content

Feature: Shallow .is checks or any "cheaper" discriminator check #1708

@a-non-a-mouse

Description

@a-non-a-mouse

There are two common use cases for .is: validation and discrimination.

Typia is often overkill for discrimination due to the amount of code it can generate for something like a JSON Schema type. For discrimination, we often don't need to validate the entire object. If there is a discriminator key, for instance, often all standard TS does is check the value of that key.

Ideally, typia could define a minimal type check to have a discriminator check based on the possible incoming types, but as I think the complexity of that is likely too high, I'm suggesting a MaxDepth param on .is or similar:

typia.is<T, N>

// or a new method to avoid over confidence

typia.isLikely<T, N=2> // 2 seems like a good default
typia.matchesToDepth<T, N=2>

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions