We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Validates an URI is a valid JSON

Hello,

I want to add "filter" to check if im getting right JSON (check if json schema is correct). Is it possible to add this filter to routes? So every route (post at last), will check if the request json schema is correct and then pass the request. Also I was thinking to add AuthFilter on some routes. Any example ?

thanks

Where do you get JSON from? Client front-end JS app?

PHP core lacks support for json schema validator, so it depends what you are planning to use.



23.6k

Where do you get JSON from? Client front-end JS app?

PHP core lacks support for json schema validator, so it depends what you are planning to use.

Yeah, from angular client front end app.. Well I was splanning to make Json filters for specific endpoints.

When you say you will validate json schema, it is expected to compare the input data with advertised schema so you'll get all required elements, with a defined type etc.

{
"type":"object",
"$schema": "https://json-schema.org/schema#",
"required":true
}

...

I'm not sure what are json filters? A set of rules for each endpoint?

Pozdrav!