johnnemo's avatar

Json Schema - Form Validation

Hello,

I am a bit confused so excuse me for the noob question.

So, would you ever use Json schema with a json schema validator ( like https://github.com/opis/json-schema ) to validate a request in your application instead of the form validation rules provided by the framework).

And if yes, what would be that case?

Thank you

0 likes
1 reply
jlrdw's avatar

Json, array, form data, makes no difference, there is one rule to always follow:

Never trust user input

That includes data coming in from another source.

Normally to work with json data in php you need to decode first anyway. I would probably validate in a custom validation class in laravel. I don't know the exact use case.

I would even make sure tags were stripped if not allowed.

A lot has to do with how much data at one time. And a lot depends on how you are using that data. If just storing in a table you could loop through the data and send through a strip_tags function. Many ways to handle it.

Please or to participate in this conversation.