Nefarious Plastic Mannequins
    Have ideas to improve npm?Join in the discussion! »

    sfn-validate-decorator
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.0 • Public • Published

    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() {
            // ...
        }
    }

    Install

    npm i sfn-validate-decorator

    DownloadsWeekly Downloads

    1

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    3.58 kB

    Total Files

    6

    Last publish

    Collaborators

    • avatar