8000 GitHub - hyurl/sfn-validate-decorator: A decorator function for SFN controllers to validate inputs.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Mar 8, 2023. It is now read-only.

hyurl/sfn-validate-decorator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sfn-validate-decorator

A decorator function for SFN controllers to validate inputs.

This package currently supports only HttpControllers, since WebSocket way to transmit data is somewhat different and cannot be tracked by the current version of SFN.

Install

npm i sfn-validate-decorator

Example

import { HttpController } from "sfn";
import { validate } from "sfn-validate-decorator";

export default class extends HttpController {
    @validate("req.body", {
        username: {
            type: "string",
            required: true,
            length: [3, 18]
        },
        password: {
            type: "string",
            required: true,
            length: [3, 18]
        }
    })
    async register() {
        // ...
    }
}

About

A decorator function for SFN controllers to validate inputs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0