Re: [RFC] JSON Schema validation support
| From: | Larry Garfield | Date: | Thu, 24 Jul 2025 14:08:49 +0000 |
| Subject: | Re: [RFC] JSON Schema validation support | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128216@lists.php.net to get a copy of this message | ||
On Thu, Jul 24, 2025, at 1:51 AM, Alexandre Daubois wrote:
> Hi Jakub,
>
> Le mer. 23 juil. 2025 à 17:41, Jakub Zelenka <bukka@php.net> a écrit :
>> In addition it could be useful to create it from array or from class (sort of auto generate
>> schema)
>
> Writing schema by hand is painful, so that would be amazing to see
> this feature land one day.
I've done a little class <--> schema translation work in the past; this is much harder
than it sounds. :-) JSON Schema is considerably more complex/robust than PHP classes, so
translating between the two is a challenge. (Maybe set hooks could cover some cases now? Hm.)
Class->schema would be easier, but in that case I think it would be better to either leave to
user-space (it would just be a bit of reflection work) or if it's in the core API to make it a
separate operation from schema validation. It's simple enough for a user to plug those two
operations together themselves when appropriate.
--Larry Garfield