diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2020-11-06 21:03:04 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2020-11-06 21:05:25 -0300 |
commit | 436939628ff1c5bbc37d5c91c4a7c68d83f12f49 (patch) | |
tree | 6930fb0cb46774c79845956a98aee7760504a208 /abdl/__init__.py | |
parent | fa55f672dfe9e20cadfef5b4ac8bb14a691277f8 (diff) |
Add optional subvalues
Diffstat (limited to 'abdl/__init__.py')
-rw-r--r-- | abdl/__init__.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/abdl/__init__.py b/abdl/__init__.py index efcd3df..7208e44 100644 --- a/abdl/__init__.py +++ b/abdl/__init__.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. -"""A Boneless Datastructure Language, version 2.1. +"""A Boneless Datastructure Language, version 2.2. ABDL expressions are regex-like constructs for matching and validating object structures. They can be used with JSON and similar formats, and even @@ -76,7 +76,11 @@ Language Reference: the enclosed ABDL expression to the value (or index) being processed. A subvalue enables the ability to match multiple values on the same object, and accepts a value if and only the enclosed expression - matches the value. + matches the value. A subvalue can be made optional by the presence of + a ``?`` after the subvalue - in case of no match, it will just omit + the relevant keys in the result. Optional subvalues are unrelated to + non-validating syntax elements (see below), they just use the same + syntax. Some syntax elements can be validating or non-validating. Validating syntax elements will raise a :py:exc:`abdl.exceptions.ValidationError` @@ -100,7 +104,7 @@ Language Reference: arrow ::= '->' keymatch ::= '[' {predicate} abdlexpression ']' - subvalue ::= '(' {predicate} abdlexpression ')' + subvalue ::= '(' {predicate} abdlexpression ')' ['?'] For a description of the terminals "parameter", "literal", "regex" and "predicate", see "Syntax Elements of ABDL Expressions" above. |