How to use the @foal/typestack.ValidateBody function in @foal/typestack

To help you get started, we’ve selected a few @foal/typestack examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FoalTS / foal / packages / acceptance-tests / src / examples / validation-and-sanitization.spec.ts View on Github external
it('Usage with a Hook', () => {
      class SocialPost {

        @Length(10, 20)
        title: string;

        @Contains('hello')
        text: string;

      }

      class SocialPostController {

        @Post()
        @ValidateBodyFromClass(SocialPost, { /* options if relevant */ })
        createSocialPost() {
          // ...
          return new HttpResponseCreated();
        }

      }

      const app = createApp(SocialPostController);

      return request(app)
        .post('/')
        .send({ text: 'foo' })
        .expect(400)
        .expect([
          {
            children: [],

@foal/typestack

FoalTS for validation and serialization using TypeStack classes

MIT
Latest version published 3 months ago

Package Health Score

73 / 100
Full package analysis