MariaDB JsonColumn Validation
Jakan opened this issue · comments
Hello,
I have a MariaDB with a table where a column corresponds to the JSON type.
Now I would like to check before inserting whether the JSON structure passed corresponds to a schema / is valid.
E.g. only the key “amount” can appear and the value can only contain numbers between 1 and 25. Is this already possible and if so, how?
Thanks
Jakan
Hi Jakan, Thank you for your question. You need to write your own 'validation.handler' and implement the check there for that specific column, see:
https://github.com/mevdschee/php-crud-api/blob/main/tests/config/base.php#L49
Hope this helps! Kind regards, Maurits
Hi,
thanks for your reply.
It works with my own validation.handler!
Greetings!