Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119650 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 88798 invoked from network); 2 Mar 2023 12:00:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Mar 2023 12:00:19 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F3D45180505 for ; Thu, 2 Mar 2023 04:00:18 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 2 Mar 2023 04:00:18 -0800 (PST) Received: by mail-wr1-f53.google.com with SMTP id h14so16274243wru.4 for ; Thu, 02 Mar 2023 04:00:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=7+Z7VTl0CT9vH5PdpHmtA1VKjsLkJf72ds9H8HDUjK0=; b=QJPG0Mp9aY6++TaBbFwpSxD9UOiS0dx5A5ckwottBR191+PMPR2XDuIbVUPQbULoms ILibPzDYgUAKOn17De/I3JT92/F7BG4iDGcDvKJnVBLyi37tEV5KMnWTe3Rajy3Y56BA GMgcjXefn0fdSKkyPb6J1a3QEiIoSNdZlbh1XpBoW8d1tapqKxE0c1dvdrUL/JIOXIkR /5igynpH6u+90i8CQBIt0o93D5xR+DdCyWdDL+BnUDRnK7VmEA/Emwd1tqVR9YKjWoHV ZPYXIyDP0KzURnlqAKmJwkSvkB3Q6ONORkjIoQdBxaTman947PkFrD7QzdiuBLjpCREF OpAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7+Z7VTl0CT9vH5PdpHmtA1VKjsLkJf72ds9H8HDUjK0=; b=iyFhfELnAda7//rk3OcoDbLa5aFijwMLh20ZCdyfwpTuc0J5OFszmirNUKZ2lyeRqm GTcV0Vdtq9yEDgSqp0xWiG+H1zTS/98jEQgBd5mxhpRPLkSmu88KqMJxm33ir8Ok1j23 2njz+VJQbxNSwinyKP+W7CrPW6rd392J6qp/3klNYlfgnD+UpAAVDoxs1iy9js4aCZ18 NhnolfgLiqC5sINR7ulj+e8iX3MkbizGbCirDcwu8Fv/dhlYOOB33fMOLPZRMsRtdSiN 8rtPlheSirNkeOlR/1nJuCDa0/o3sNalOinRF7rZCHjATDpK5ORNtGSq7i+1bFyhEt3D lwbA== X-Gm-Message-State: AO0yUKUo+geh1QqD0hFhnhlfacn2GV7EN1rl5g0CkDrxZrEjrgHLJxi2 lyhC/5jZaKUZ9RFM2vOMCaEOSYK7pWv5qUHdaV+aIoFTpDo= X-Google-Smtp-Source: AK7set8s7fkAqzSQdhVNesVmHnBT+8ndsriw9ivcrr6cU+w6GP3glqMTxQVny+TpMe9gO9lz4RAwgphZKYjCtrKAMkA= X-Received: by 2002:a5d:5089:0:b0:2c9:59c3:1f52 with SMTP id a9-20020a5d5089000000b002c959c31f52mr1694449wrt.0.1677758417218; Thu, 02 Mar 2023 04:00:17 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 2 Mar 2023 12:00:05 +0000 Message-ID: To: PHP Internals List Content-Type: multipart/alternative; boundary="0000000000007a33df05f5e99211" Subject: Re: [PHP-DEV] RFC Idea - json_validate() validate schema From: rowan.collins@gmail.com (Rowan Tommins) --0000000000007a33df05f5e99211 Content-Type: text/plain; charset="UTF-8" On Wed, 1 Mar 2023 at 11:44, juan carlos morales wrote: > I am thinking about enhancing this function to also be able to > validate against a JSON SCHEMA, giving us something like this: > > json_validate(string $json, int $depth = 512, int $flags = 0, string > $json_schema = null): bool > Functionally, I think this is sounds great. My only concern is that JSON Schema is a bit of a moving target. Unlike XSD, which has only ever had two revisions, 10 years apart (1.0 from 2001, and 1.1 from 2012), JSON Schema is in active development, with "Draft-07", "2019-09", and "2020-12" all seeing deployment as stable releases, and work in progress on a new version: https://github.com/json-schema-org/json-schema-spec/milestone/7 That raises two questions: * Which existing version(s) of the specification will be implemented? For instance, if I have a schema written for 2019-09 rather than 2020-12, will I be able to use this validator? * How will new versions of the specification be added to the parser? If PHP 8.4 is release in November 2024, and JSON Schema 2025-01 is published two months later, will I need to wait for PHP 8.5 to use the new specification? I guess the combination of those leads to a third question: will support for some versions be *removed* in later PHP versions, so that each PHP version will have a minimum and maximum schema version it supports? That's the big disadvantage of anything shipped in core, rather than in an extension or library - there is no way to make even minor changes outside of PHP's release cycle. I wonder if there's some way this can be made pluggable - ship the core mechanisms needed by the validator in core, but make them accessible to libraries to implement specific specifications in an efficient way. This is the approach taken by the MongoDB PHP driver - there's a stable extension providing efficient low-level routines, then a decoupled PHP library which can be installed at the project level, and follow a much more agile release process. I'm not sure what it would look like in this case, but may be worth considering. Regards, -- Rowan Tommins [IMSoP] --0000000000007a33df05f5e99211--