Closed recanman closed 2 years ago
I think using something like t inside your TakeInput
function makes the most sense. If you want to use a middleware layer, there's no reason why you couldn't build this already.
local validators = {
["TakeInput"] = t.tuple(t.number, t.string)
}
local service = Knit.CreateService({
Name = "Test",
Middleware = { Inbound = { createValidatorMiddleware(validators) } }
})
Didn't know about this. Thanks for linking the resource!
Currently, it is hard to validate inputs for my services without making classes for functions that use the same set of arguments.
If the function name being executed is added to middleware, that would certainly improve my workflow since I would be able to easily work with validation of input and separate it from the actual function itself (so the top of each function isn't just a chain of
if not x then return end
, or similar).An example that uses the function name: