MichalLytek / MichalLytek/class-transformer-validator

Simplified usage for type guards

Open
#14 5 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
205
Forks
20
PR merge metrics
No merged PRs in 30d

Description

I'm currently using this package with a helper to create type guards:
```ts
/** Create a type guard function for a class decorated with validators. */
export function isValidFactory(classType: ClassType): (instance: object) => instance is T {
return (instance: object): instance is T => {
try {
transformAndValidateSync(classType, instance)
return true
} catch (err) {
return false
}
}
}
```

Would you be interested in a PR that adds this helper?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the existing transformAndValidateSync helper, ClassType definition, and public exports. If the proposal is accepted, add the type-guard helper and verify behavior for valid and invalid instances using the package's existing validation tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.