Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would a "required" spec be useful? #12

Open
tucotuco opened this issue Mar 2, 2017 · 2 comments
Open

Would a "required" spec be useful? #12

tucotuco opened this issue Mar 2, 2017 · 2 comments

Comments

@tucotuco
Copy link

tucotuco commented Mar 2, 2017

This would be a data set level specification. A list of fields that must be found in the input.

Related, what would the implementation expectation be for a specification that can not be validated because the field is not in the input?

@tucotuco tucotuco changed the title Would a "required" spec be useful Would a "required" spec be useful? Mar 2, 2017
@peterdesmet
Copy link
Member

We had a required at one point, but you can replicate it with:

sex:

Or for multiple fields:

sex:
lifeStage:
recordedBy:

Listing a field in the specifications will trigger a test for that field. If that field cannot be found, than the implementation will throw an error.

However, empty: False is implied by default for any field (the field cannot be empty). So, if you rather just know if a field is available, without making any statements about its content, you should use:

sex:
  empty: True

Also note that the specifications dictate what will be tested in the data file, not the other way. So if a data file contains fields that are not listed in the specification, that this will not throw any warning or error.

@peterdesmet
Copy link
Member

Oh, the required we had was also term1 : required, term2 : required not required: term1, term2 as you suggest. Anyway, I like the syntax as in my previous comment, because it does not break the term: specification pattern.

Also, it allows to start a specification quite gentle:

scientificName:
  empty: True

recordedBy:
  empty: True

(both terms above should be in the file)

And you can extend it easily to a more robust specification:

scientificName:
  allowed: [...]

recordedBy:
  delimitedvalues:
    delimiter: " | "
    regex: ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants