Crazy idea:
In Kenji, an input validation might be written declaratively, above the route, instead of as code within the route.
Code could look like this:
validate! do
# symbols are path params
validates_type_of :id, is: Blah
# string are body keys
validates_type_of 'name', is: String
end
post '/friends/:id' do
# method body
end
Or:
post '/friends/:id',
validate: -> {
# symbols are path params
validates_type_of :id, is: Blah
# string are body keys
validates_type_of 'name', is: String
} do
# method body
end
Here, we gain the ability to:
- validate path params, and passed vars, instead of only body
- run validations only with no additional code (magic VALIDATE http method)
Crazy idea:
In Kenji, an input validation might be written declaratively, above the route, instead of as code within the route.
Code could look like this:
Or:
Here, we gain the ability to: