kodepandai / lunox

Laravel-Flavoured Nodejs Framework
https://lunox.js.org
MIT License
77 stars 8 forks source link

[lunox-core] Eject Validation to separate module #39

Closed axmad386 closed 1 year ago

axmad386 commented 1 year ago

currently lunoxjs has builtin form validation that can be accessed using req.validate() method. But under the hood it using https://github.com/kodepandai/node-input-validator. But sometimes user prefer using third party for validation eg: zod. So IMO, it's better to move this feature to separate module called @lunoxjs/validation.

But may be we got some problem here, since this validation is attached to Request class. So we should use macro to extend this functional. maybe something like this in

// in ValidationServiceProvider
register(){
  Request.macro('validate', callback here)
}

Also we need to extend the Request interface using Module Augmentation