joshgallagher24
2 years ago
54
3
Lumen

Wrapping Validation Errors in 'data'

Posted 2 years ago by joshgallagher24

Hi all,

I have a validator in my Lumen project, specifically in my auth controller sign up method. It returns errors like this:

{
    "name": [
        "The name field is required."
    ],
    "email": [
        "The email field is required."
    ],
    "password": [
        "The password field is required."
    ]
}

But I would like them returned like this:

"data": [
    {
    "name": [
            "The name field is required."
        ],
        "email": [
            "The email field is required."
        ],
        "password": [
            "The password field is required."
        ]
    }
]

Anyone know how to do this in Lumen? I know in Laravel you can extend the form requests class, but that is not available in Lumen.

Please sign in or create an account to participate in this conversation.