@atscript/moost-validator
v0.1.47
Published
Validator pipe and utils for Moost.
Downloads
1,799
Maintainers
Readme
Drop-in Atscript validation for the Moost framework. Automatically validates handler parameters against .as model constraints — no manual validate() calls needed.
Installation
pnpm add @atscript/moost-validatorPeer dependencies: moost, @moostjs/event-http, @atscript/core, @atscript/typescript.
Quick Start
import { Moost } from 'moost'
import { validatorPipe, validationErrorTransform } from '@atscript/moost-validator'
const app = new Moost()
app.applyGlobalPipes(validatorPipe())
app.applyGlobalInterceptors(validationErrorTransform())Any handler parameter typed with an Atscript-compiled class is now automatically validated. On failure, a 400 Bad Request response is returned with structured error details.
Features
- Automatic validation — runs during the
VALIDATEpipeline stage before business logic - Composable — apply globally or per-controller/handler via
@UseValidatorPipe() - Clean error responses — interceptor converts
ValidatorErrortoHttpError(400) - Validator options —
partial,unknownProps,errorLimit,plugins - Zero runtime dependencies — everything via peer deps
Documentation
License
MIT
