Re: [Json] Another problematic JSON Schema use-case

Carsten Bormann <cabo@tzi.org> Thu, 26 May 2016 16:12 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 0728B12D743 for <json@ietfa.amsl.com>; Thu, 26 May 2016 09:12:30 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.601
X-Spam-Level:
X-Spam-Status: No, score=-2.601 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Pg18YmLCJ-Ai for <json@ietfa.amsl.com>; Thu, 26 May 2016 09:12:27 -0700 (PDT)
Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 3A17012D741 for <json@ietf.org>; Thu, 26 May 2016 09:12:27 -0700 (PDT)
Received: from mfilter47-d.gandi.net (mfilter47-d.gandi.net [217.70.178.178]) by relay6-d.mail.gandi.net (Postfix) with ESMTP id 6751EFB974; Thu, 26 May 2016 18:07:42 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mfilter47-d.gandi.net
Received: from relay6-d.mail.gandi.net ([IPv6:::ffff:217.70.183.198]) by mfilter47-d.gandi.net (mfilter47-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id ejY7HX_oIHlX; Thu, 26 May 2016 18:07:40 +0200 (CEST)
X-Originating-IP: 93.199.242.26
Received: from nar-3.local (p5DC7F21A.dip0.t-ipconnect.de [93.199.242.26]) (Authenticated sender: cabo@cabo.im) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 81572FB97C; Thu, 26 May 2016 18:04:22 +0200 (CEST)
Message-ID: <57471E84.7010503@tzi.org>
Date: Thu, 26 May 2016 18:04:20 +0200
From: Carsten Bormann <cabo@tzi.org>
User-Agent: Postbox 4.0.8 (Macintosh/20151105)
MIME-Version: 1.0
To: Tim Bray <tbray@textuality.com>
References: <CAHBU6ivd5JJ7Hx_JtNPSnW40jXzEF1Yr7=rwuZzGnFrRoMphbg@mail.gmail.com> <CANkuk-WppF4WgeZc5OX2-tozmCd+eYtPwFgmDtoiJHxwdSjDzw@mail.gmail.com> <CAHBU6iu_nYyUBS-8PAJ3zER=RNKfiV532vEOeOnfr5eXbPv8Tw@mail.gmail.com> <CAAQiQRdu2pixrXhuqqmWGjdab6_mCMVcPTKWQQu=Oh0n3MmW0g@mail.gmail.com> <5745EE5E.5050801@tzi.org> <CAAQiQRcgKe=V1rmgZnMdQLdJEiftKP1fvbQRG15_AfdAVxqh1A@mail.gmail.com> <CAHBU6iv_ReUfUhP93hy9_npub4nqxoywKtVh65xbc6_DmqDMJw@mail.gmail.com>
In-Reply-To: <CAHBU6iv_ReUfUhP93hy9_npub4nqxoywKtVh65xbc6_DmqDMJw@mail.gmail.com>
X-Enigmail-Version: 1.2.3
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
Archived-At: <http://mailarchive.ietf.org/arch/msg/json/3HQm8Fu-nA02_Ynrcn5k8WWDUno>
Cc: json@ietf.org
Subject: Re: [Json] Another problematic JSON Schema use-case
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/json/>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 26 May 2016 16:12:30 -0000

Tim Bray wrote:
> So, to close the loop, here's how I worked around the problem. I
> auto-processed my large schema with a Ruby script to generate a small
> schema for each of the "Type":"Animal/Vegetable/Mineral" variations,
> then if the large schema reports any errors, I run through the objects
> validating each with the appropriate micro-schema.  This way, I almost
> always get a human-comprehensible error message.

>From a grammar validation point of view, you believe the type field more
than the other fields, so if there is a conflict between them, the type
field wins and the other fields can thus be flagged as wrong.

In a definite clause grammar (DCG), cuts can be used to elicit similar
behavior.  There are proposals for cut points in parse expression
grammars (PEGs); maybe that is a good subject for further evaluation.

Grüße, Carsten