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

Add the interface name in the TypeGuardError #1055

Open
vabatta opened this issue May 10, 2024 · 0 comments
Open

Add the interface name in the TypeGuardError #1055

vabatta opened this issue May 10, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@vabatta
Copy link

vabatta commented May 10, 2024

Description

When a typia.assert<T>() throws the TypeGuardError, would be nice to have the original T name interface as part of the Error object thrown so that it can be used to connect which interface has thrown.

Example

From the doc:

import typia, { tags } from "typia";
import { v4 } from "uuid";
 
typia.assert<IMember>({
  id: v4(),
  email: "samchon.github@gmail.com",
  age: 18, // wrong, must be greater than 19
});
 
interface IMember {
  id: string & tags.Format<"uuid">;
  email: string & tags.Format<"email">;
  age: number &
    tags.Type<"uint32"> &
    tags.ExclusiveMinimum<19> &
    tags.Maximum<100>;
}

Would throw

method: typia.assert()
path: input.age
+ interface: IMember
value: 18,
expected: number & ExclusiveMinimum<19>

Or with a change in the API

method: typia.assert()
+ path: IMember.age
value: 18,
expected: number & ExclusiveMinimum<19>
@samchon samchon self-assigned this May 22, 2024
@samchon samchon added good first issue Good for newcomers enhancement New feature or request labels May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants