Skip to content

Decorator based usage for typia.functional.assertEqualsFunction #1586

Description

@zareith

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions