Re: [RFC] JSON Schema validation support
| From: | Jakub Zelenka | Date: | Wed, 23 Jul 2025 15:41:47 +0000 |
| Subject: | Re: [RFC] JSON Schema validation support | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128198@lists.php.net to get a copy of this message | ||
Hi Alex,
On Wed, Jul 23, 2025 at 3:57 PM Alexandre Daubois <
alex.daubois+php@gmail.com> wrote:
> Thank you for proposing such a feature! I personally really like it
> and would be glad to see this land into PHP.
> I think it would be even more useful if JsonSchema offers more ways to
> load a schema. Schemas are often either remotely stored or stored in a
> file.
>
Yes, this is exactly the reason why it's using a static method and not a
constructor
It would be great to add two new factory methods:
> JsonSchema::fromUri() and JsonSchema::fromFile().
Yeah something like this is planned in the next stage. In addition it could
be useful to create it from array or from class (sort of auto generate
schema) as well but that's all feature scope.
> Maybe
> JsonSchema::createFromString() should also be renamed to fromString()
> to be consistent with the recent additions to XMLReader.
>
I actually took that name from recently
introduced HTMLDocument::createFromString and XMLDocument::createFromString
. So not sure what is more consistent. Personally I don't really mind.
Kind regards
Jakub