abduljakul-salsalani
1 week ago
123
5
Laravel

How do you validate a json object in with an npm

Posted 1 week ago by abduljakul-salsalani

$this->validate(request('form.display_name'),[
                'display_name' => 'required|min:3|max:100',
                ...
]);

I want to be able to validate this request. but I want I have it like in an object so in my axios

axios.put(this.endpoint, { 
                form : this.form , 
                image : this.image
            }).then(response => {
                console.log(response.data);             
            }).catch(error => {
                console.log(error);
            });

So my question is how will I validate that request with $this->validate since it's in an object.. so in my chrome devtools it would look like

form: {username: "chandler40", email: "[email protected]", id: 1, current_password: "secret",…}
image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAA",

how will I validate those in my controller ? since it's a json object ?

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