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

[SCHEMA] Add patterns for format validation #885

Merged
merged 34 commits into from
Mar 24, 2022
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7262fda
Draft formats file.
tsalo Sep 24, 2021
f9a5d15
Limit time zones to between 3 and 4 characters.
tsalo Sep 24, 2021
0d053d8
Add stimuli_relative format.
tsalo Sep 24, 2021
f53d806
Don't allow absolute paths or problematic start folders.
tsalo Sep 24, 2021
e6aa4b3
Use URI regex.
tsalo Sep 24, 2021
35cf7c2
Fix(?) BIDS URI regex.
tsalo Sep 24, 2021
40fa1d2
Update formats.yaml
tsalo Sep 24, 2021
00aef74
Don't allow just zeros in index regex.
tsalo Sep 24, 2021
7143ee8
pattern --> format.
tsalo Sep 24, 2021
a3fda8e
Document the rules for the different formats.
tsalo Sep 24, 2021
5b9ccbb
Merge branch 'bids-standard:master' into format-rules
tsalo Oct 5, 2021
dfd3057
Remove fancy n/a handling.
tsalo Oct 14, 2021
89b37e6
Move formats file into rules folder.
tsalo Oct 14, 2021
25944e7
Actually, the individual formats are really objects.
tsalo Oct 14, 2021
3189a88
Add patterns for rrid and time.
tsalo Oct 14, 2021
a2e56b0
Be more specific with RRIDs.
tsalo Oct 15, 2021
3a2eac3
Remove anchors around patterns and add quotes.
tsalo Dec 6, 2021
f9c316c
Replace double-quotes with single-quotes.
tsalo Dec 6, 2021
998742a
Merge branch 'master' into format-rules
tsalo Jan 5, 2022
cc502c5
Draft a test for formats.
tsalo Jan 5, 2022
30e7358
Add names for tests. They probably won't ever be used.
tsalo Jan 5, 2022
fa6256c
Add more valid pattern tests.
tsalo Jan 5, 2022
b57d891
Fix mistake in date/datetime patterns.
tsalo Jan 5, 2022
a9abc49
Make time part of datetimes more restrictive.
tsalo Jan 5, 2022
755285a
Make datetimes more robust.
tsalo Jan 5, 2022
b92aa0f
Add more bad-pattern checks.
tsalo Jan 5, 2022
9e2b6cf
Apply suggestions from code review
tsalo Jan 5, 2022
245e149
Merge branch 'format-rules' of https://github.com/tsalo/bids-specific…
tsalo Jan 5, 2022
e5e3563
Test the new pattern changes.
tsalo Jan 5, 2022
9284172
Merge branch 'master' into format-rules
tsalo Feb 1, 2022
aea7982
Apply suggestions from code review
tsalo Feb 2, 2022
84061cc
Reorder formats alphabetically within each section.
tsalo Feb 2, 2022
df0dd34
Run black on test and improve check.
tsalo Feb 2, 2022
4a0ad3f
Comment out failing pattern, but add a note about it.
tsalo Feb 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions src/schema/formats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
# This file defines valid patterns for different formats
# Entity patterns
label:
description: |
Freeform labels without special characters.
pattern: ^[0-9a-zA-Z]+$
index:
description: |
Non-negative, non-zero integers, optionally prefixed with leading zeros for sortability.
pattern: ^[0-9]+$
# Metadata types
string:
description: |
A basic string type (not a specific format).
This should allow any free-form string *except* "n/a".
pattern: ^(?!(n/a)$).*$
tsalo marked this conversation as resolved.
Show resolved Hide resolved
integer:
description: |
An integer.
pattern: ^[+-]?\d+$
number:
description: |
A number.
pattern: ^[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)$
boolean:
description: |
A boolean.
pattern: ^(true|false)$
# String patterns
date:
tsalo marked this conversation as resolved.
Show resolved Hide resolved
description: |
A date.
YYYY-MM-DD[Z]
pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}?[A-Z]*$
datetime:
description: |
A datetime.
YYYY-MM-DDThh:mm:ss[.000000][Z]
pattern: ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}?(\.[0-9]{1,6})?([A-Z]{3,4})$
unit:
description: |
A unit.
Currently this matches any string that isn't "n/a"
TODO: Somehow reference the actual unit options in the Units appendix.
pattern: ^(?!(n/a)$).*$
dataset_relative:
description: |
A path to a file, relative to the dataset folder.

The validation for this format is minimal.
pattern: ^[0-9a-zA-Z/_-\.]+$
participant_relative:
description: |
A path to a file, relative to the participant's folder in the dataset.

The validation for this format is minimal.
pattern: ^[0-9a-zA-Z/_-\.]+$
uri:
description: |
A uniform resource indicator.
pattern: ^[a-zA-Z]+:[0-9a-zA-Z/_-\.]+$
bids_uri:
description: |
A BIDS uniform resource indicator.
pattern: ^bids:[0-9a-zA-Z/_-\.]+$
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patterns for all four of the path/URI formats should be revised. I don't know enough about the rules to define solid patterns just yet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same goes for stimuli_relative (added after the initial comment).