Skip to content

Commit

Permalink
Update allowed-values docs and explain default value (#251)
Browse files Browse the repository at this point in the history
* Update allowed-values docs for #248.

Co-authored-by: David Waltermire <david.waltermire@nist.gov>
  • Loading branch information
aj-stein-nist and david-waltermire authored Nov 7, 2022
1 parent 675d385 commit 529ff85
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions website/content/specification/syntax/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -646,23 +646,25 @@ Additionally, line feed (LF) characters must be escaped as "\\n" when appearing

Additionally, flags may be constrained to a set of known values listed in advance.

This restriction can be either strict (values must be in the list for document validity) or loose (i.e. for documentation only, no effect in schemas).
This restriction can be either:

Use the `valid-values` element to restrict the permissible values for a flag. Set its attribute `allow-other='yes'` if the list is not exclusive.
1. strict (values must be in the list for document validity with `allow-other="no"` attribute for an `allowed-values` element) or
2. loose (i.e. for documentation only, no effect in schemas, with `allow-other="yes"`).

Within it `valid-values`, a `value` element's `@name` attribute assigns the permissible value, while its data content provides documentation. For example:
If an `allowed-values` constraint does not have the `allow-other` attribute defined, the default is `allow-other="no"`, resulting in strict validation where the only valid values are those in the list.

Within `allowed-values` of a `constraint`, an `enum` element's `@value` attribute assigns the permissible value, while its data content provides documentation. For example:

```xml
<define-flag name="algorithm" datatype="string">
<formal-name>Hash algorithm</formal-name>
<description>Method by which a hash is derived</description>
<valid-values allow-other="yes">
<value name="SHA-224"/>
<value name="SHA-256"/>
<value name="SHA-384"/>
<value name="SHA-512"/>
<value name="RIPEMD-160"/>
</valid-values> ...
<constraint>
<allowed-values allow-other="yes">
<enum value="SHA-224">Documentation for one permissible option.</enum>
<enum value="SHA-256">Documentation for another permissible option.</enum>
</allowed-values>
</constraint> ...
```
## Metaschema modeling

Expand Down

0 comments on commit 529ff85

Please sign in to comment.