Middlware props pipe expression

According to the documenration (https://adonisjs.com/docs/4.0/middleware#_middleware_props) I assumed the middleware props support the pipe (or QS expressions)
however when I provide a expression as explained in haye documentation I didn’t receive the parameters properly broken into a array of (json format)

ex: if I use the following as a prop to Middleware
'required|email:unique,users'

I’ve got an array with only one element (‘required’)

image

Does this mean even though documentation mentioned that it supports pipe expression it only supports comma separated list? Or am I doing something wrong here.

The documentation is a bit misleading in this case. If you check the source code you’ll find those rows:

const [{ name, args }] = haye.fromPipe(middleware).toArray()
const packet = this._middleware.named[name]

So yes, it’s using haye to parse a string you pass from the router but destructure and use only first array item. So everything you can pass to the middleware are just it’s name and array of args. Like:

middleware(['name:arg1,arg2,arg3'])
2 Likes

Thank you, yes it is misleading when it says it follows pipe expression, thanks