Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BC52C200D4B for ; Mon, 27 Nov 2017 18:47:23 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id BACA3160C13; Mon, 27 Nov 2017 17:47:23 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0D752160BFA for ; Mon, 27 Nov 2017 18:47:22 +0100 (CET) Received: (qmail 84387 invoked by uid 500); 27 Nov 2017 17:47:22 -0000 Mailing-List: contact user-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@avro.apache.org Delivered-To: mailing list user@avro.apache.org Received: (qmail 84377 invoked by uid 99); 27 Nov 2017 17:47:22 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Nov 2017 17:47:22 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 3B789C5715 for ; Mon, 27 Nov 2017 17:47:21 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.079 X-Spam-Level: X-Spam-Status: No, score=0.079 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, KB_WAM_FROM_NAME_SINGLEWORD=0.2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id iThnnOvTr1Oi for ; Mon, 27 Nov 2017 17:47:17 +0000 (UTC) Received: from mail-it0-f41.google.com (mail-it0-f41.google.com [209.85.214.41]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 502C95F23E for ; Mon, 27 Nov 2017 17:47:17 +0000 (UTC) Received: by mail-it0-f41.google.com with SMTP id b5so22072131itc.3 for ; Mon, 27 Nov 2017 09:47:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=0QQztbDK6Ubi71n5VE7SF+UoI4LGw9+zubTlVPy9Wf4=; b=HkxjTXjqxh+zlr3ydADAS+fWEiicV28SkkvdJCpL6aVFEB7isN+YUYGCK/NSApZYo+ E8FG6Gqmvzc1XPwhNam2YxTROHFLLAwcVmYfyQDm7WrvLsPhQ3vRs+G9d57ofOElPS4b 84qjOdYqcdIKIc81X1Fe3IkShgzbZUWENsLZl8PDd6LD6hXa8wM/tb32X+ar9YqpJuH+ od5EJaVyUvENMUE13fWoU/b2p/OXjQGOk7q8h8LQMXojPbZMy9pqAuvqnvFY1ZC6Jbvp 0BAPY/A7YXMwSTDKcgdi+zV8+7LW0wiD33sWo1XfDFI6kVlxhLDXDTFvlRvgZHfLZiBJ n9cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=0QQztbDK6Ubi71n5VE7SF+UoI4LGw9+zubTlVPy9Wf4=; b=HGHeznQzS5OaV/wlF8I2oI/tHPoEIgBZGEicrLHnKf17L80ijToy3M1wnq05zzZ5Lv Q/Rzx86ez2hEg2Y53nhUvDOVEoNFlG+cfHfMPk00zcTmlJewDzd7NXeZcPsjJUkPcjde xSOFr75zua/BCz5Iz5+ibYw6p2rdP8oEGA0qJdG6Qh1dHF0/dceZ7R0Sh6MmvcDwiATd oeBsTW9Als8+TMuIG+8M/mXUWf9jpMj+39PpXXX59gQzne3EdDEk9BFKmh8cB07ypQJV 6FzqI768mdLBgfJLgNzQE0Kpcrnx1MRcIJlSYjQYgU+uCcc60LbZletUoThc75a0Pnks z6og== X-Gm-Message-State: AJaThX4+ZjGcLI7RivPP+cumSpaguNzxJLHRCmpZ2fjYHF6ztvlp5qVA nD0jrBDVvblTyPiSNkRkpOcK4LTt4XIua2tgHhAQSg== X-Google-Smtp-Source: AGs4zMa4XQoRhSNQOws1Cv+EglBrSbIEZyjlJFLRc5xHFhL/TuFH9AsBmidfFgpzzi2QmW4BqhgatyxHJQjX3SdT/GQ= X-Received: by 10.36.48.82 with SMTP id q79mr32276633itq.75.1511804831177; Mon, 27 Nov 2017 09:47:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.242.18 with HTTP; Mon, 27 Nov 2017 09:47:10 -0800 (PST) In-Reply-To: References: From: Dan Schmitt Date: Mon, 27 Nov 2017 12:47:10 -0500 Message-ID: Subject: Re: how to do non-optional field in nested object? To: user@avro.apache.org Content-Type: text/plain; charset="UTF-8" archived-at: Mon, 27 Nov 2017 17:47:23 -0000 I'm using the C++ api to do validation outside what I can specify in the schema spec. On Mon, Nov 27, 2017 at 11:12 AM, Martin Mucha wrote: > Following schema: > { > "name" : "ARecord", > "type" : "record", > "namespace" : "AAA", > "fields" : [ > {"name": "A", "type": "string" } > ] > } > > > does not validate json > > {} > > as valid one. It's invalid. A is required, as would be expected by me. > > --- > I'm getting lost here. > What is the resolution? I kinda wanted to use avro schema to validate > described JSON, and now based on what you said IIUC validation in "xschema > style": "1 of this, followed by 2 of that" is not possible with avro schema. > Correct? > > > Btw. what do you use to validate JSON using avro? I used avro-utils.jar > executed from command line, which proved as incapable of deserializing & > validating optional fields if they are set (if optional field is set, I have > to pass value in json like: {"string":"value"}). So now I'm using for > testing purposes actual flow through NIFI, which is extremely cumbersome. > > 2017-11-27 16:19 GMT+01:00 Dan Schmitt : >> >> The top level object in all the examples is a record (of which you can >> have 0 or more.) >> >> So, right now, even the top level is failing the spec: >> >> IV) valid (0 ARecords): >> { } >> >> V) valid (2 ARecords): >> { >> "id": "...", >> "B": { >> "C": "..." >> } >> } , >> "id": "...", >> "B": { >> "C": "..." >> } >> } >> >> On Mon, Nov 27, 2017 at 9:47 AM, Martin Mucha wrote: >> > I don't understand where "or more" is comming from. >> >> Because of the use of nested records. Anywhere you put a record you can >> have 0, >> or more than 1. I don't know of a pure schema way to enforce only >> 1/optional. >> >> If you are doing something with any of the APIs you could add a validation >> step >> that says "must have only 1 ARecord, and must have only 1 BRecord" after >> you >> read the data and throw an error for the 0 or 1+ situations, but you'd >> need to write >> some code somewhere with one of the APIs and build your own validator. > >