typia icon indicating copy to clipboard operation
typia copied to clipboard

Decorator based usage for typia.functional.assertEqualsFunction

Open zareith opened this issue 7 months ago • 1 comments

Hello, thank you for maintaining and open-sourcing typia. Really love the DX this library offers.

Feature Request

I am using typia.functional module to guard function parameters and return values.

While this works great for standalone functions, it would be great if we could use this (or a similar utility) as decorators on class methods too.

Suggested API:

class UserService {
    @typia.decorators.assertEquals
    async findMany(query: UserQuery) {
        // We only reach here if query is validated to be UserQuery
    }
}

Currently it is possible to do something like this:

class UserService {
    findMany = typia.functional.assertEquals(async (query: UserQuery) => {
        // We only reach here if query is validated to be UserQuery
    })
}

But this doesn't work well if you need other decorators on that method, or need inheritance.

zareith avatar May 21 '25 17:05 zareith

There had been @AssertType() decorator function in typescript-is.

As I am concentrating on AI development, I cannot sure when I can start this ticket, but this idea seems good.

samchon avatar Jun 24 '25 08:06 samchon