Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @t2ee/validation with all npm packages installed. Try it out:

require("@t2ee/core/package.json"); // @t2ee/core is a peer dependency. require("typescript/package.json"); // typescript is a peer dependency. require("reflect-metadata/package.json"); // reflect-metadata is a peer dependency. var validation = require("@t2ee/validation")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@t2ee/validation v1.0.2

validation

Introducation

This library fully uses the advantages of decorators, make it smooth to write validation rules.

For detailed introductions and examples, please visit validation.t2ee.org.

Installation

npm i reflect-metadata @t2ee/core @t2ee/validation -S

Example usage with @t2ee/vader

class Message {
    @NotNull
    @Min(4)
    message: string;
}

@Path('/')
@Component
class Controller {

    @POST
    @Path('/say')
    say(@Valid @Body message: Message) {
        // message should be at least 4 characters long
    }
}
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free