W3C home > Mailing lists > Public > public-bioschemas@w3.org > October 2017

Re: Array validation

From: Leyla Garcia <ljgarcia@ebi.ac.uk>
Date: Mon, 16 Oct 2017 17:10:14 +0100
To: BATISTA Dominique <Dominique.BATISTA@france-bioinformatique.fr>, "public-bioschemas@w3.org" <public-bioschemas@w3.org>
Message-ID: <4d510641-764d-b4ec-8cc6-ff173b786b4d@ebi.ac.uk>
Hi Dominique,

Perfect! It makes total sense. Just wanted to be sure we were doing it 
alright for the validator. Thanks!

Cheers,

On 16/10/2017 17:06, BATISTA Dominique wrote:
> Hello Leyla,
>
> You can definitely use single values outside arrays if you have a 
> multiple values field but only have one value to provide. I'd even go 
> further and promote the use of arrays *only* when more than one value 
> is to be provided.
> It doesn't make a lot of sense programaticaly to use an array 
> structure when you only have one object to provide.
>
> The logic behind my code goes like this:
>
> myjson = json_to_validate;
> for (field in myjson){
>     if (typeof(field)=="string") { process_string(field); }
>     else if (typeof(field)=="object") { process_object(field); }
>     else if (typeof(field)=="array") {
>         for (value in field) {
>             if (typeof(value)=="string"){ process_string(value); }
>             elseif (typeof(value)=="object") { process_object(value); }
>         }
>     }
> }
>
> It doesn't matter how you provide your single values. Whichever you 
> choose to use (an array or not), it will find a corresponding condition.
>
> Hope this answered your question :)
>
> Best regards,
>
> Dominique Batista
> Ingénieur Web IFB Core
> CNRS - UMS3601
> Tel: 01.69.82.46.92
> Site: http://www.france-bioinformatique.fr
> ------------------------------------------------------------------------
> *From:* Leyla Garcia [ljgarcia@ebi.ac.uk]
> *Sent:* Monday, October 16, 2017 5:46 PM
> *To:* public-bioschemas@w3.org; BATISTA Dominique
> *Subject:* Array validation
>
> Hi Dominique,
>
> It came to my mind that in the validator, when an array is expected, 
> you validate that at least one element is present.
> If it is only one element, does it have to be inside an array? In 
> schema.org, as many are always possible, if you need only one, then 
> you do not use an array.
>
> For instance, for adataset you can have multiple distributions:
> "distribution": [
>
> {
>
> "@type": "DataDownload",
>
> "name": "UniParc XML",
>
> "fileFormat": "xml",
>
> "contentURL": 
> "ftp://ftp.uniprot.org/pub/databases/uniprot/current_release/uniparc/uniparc_all.xml.gz" 
>
>
> },
>
> {
>
> "@type": "DataDownload",
>
> "name": "UniParc FASTA",
>
> "fileFormat": "fasta",
>
> "contentURL": 
> "ftp://ftp.uniprot.org/pub/databases/uniprot/current_release/uniparc/uniparc_active.fasta.gz" 
>
>
> }
>
> ],
>
> Or you can have only one:
> "distribution":
>
> {
>
> "@type": "DataDownload",
>
> "name": "UniParc XML",
>
> "fileFormat": "xml",
>
> "contentURL": 
> "ftp://ftp.uniprot.org/pub/databases/uniprot/current_release/uniparc/uniparc_all.xml.gz" 
>
>
> },
>
>
> And both are valid in Bioschemas. Will both of them become as valid in 
> your validator?
>
> Regards,
Received on Monday, 16 October 2017 16:10:40 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:07:59 UTC