Skip to content
Open
Changes from all commits
Commits
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
12 changes: 10 additions & 2 deletions Documentation/UserManual/restrictions.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ Here are some common examples you can use:

Note that Regex has multiple "flavours" or "dialects", so although the first two links are useful learning resources, they may also include Regex features not available in IDS. The third link (XML Regular expressions) can be referenced as an authoritative source on what can be used in IDS. In general, Regex in IDS is simpler and does not include advanced Regex features.

One flavour difference is worth calling out on its own, because it does not cause an error, it silently changes the result. **IDS patterns must match the whole value, not part of it.** Every example in the table above relies on this. `DT[0-9]` rejects "`DT123`" precisely because the pattern has to account for the entire value, not just find "`DT1`" inside it.

Most general purpose Regex testers, including regex101.com, search for a *matching part* of the value instead. Testing `DT[0-9]` against "`DT123`" there reports a match, which is the opposite of what IDS does. To reproduce IDS behaviour in such a tool, wrap the pattern in `^` and `$`, for example `^DT[0-9]$`. **Do not copy those anchors back into the IDS pattern**, they are not needed and `^` and `$` are not part of the XML Schema Regex syntax.

Length limiting patterns are a common way to hit this difference. In IDS, the pattern `.{1,5}` accepts only values that are one to five characters long, because the whole value has to fit the pattern. An unanchored tester appears to accept longer values too, since it quietly matches just the first five characters inside them.

Testers that implement XML Schema Regex directly avoid this problem, since they apply whole value matching automatically. Two free online examples are [DevToys XSD Regex Tester](https://devtoys.pro/testers/xsd-regex) and [Xsd Pattern Tester](https://online-xsd-pattern.vercel.app/). These are third party tools and are not affiliated with buildingSMART.

## Bounds

A **Bounds** restriction allows you to specify that the value is a number and has to fall within a range of values. You can specify either a minimum, maximum, or both. You can also specify whether the minimum or maximum is inclusive (e.g. `>=` and `<=`) or exclusive (e.g. `>` and `<`). For example, you might specify that a value needs to be "more than 3" and "less than or equal to 10".
Expand All @@ -53,6 +61,6 @@ A **Bounds** restriction allows you to specify that the value is a number and ha

A **Length** restriction specifies the exact number of characters allowed in a value. For example, if you specify a length of 3, then values that are three characters long, like "`ABC`" or "`123`", will meet your requirement. Other values, like "`AB`" or "`ABC123`" will not meet your requirement.

Similarly, you can specify a **Max Length** and / or a **Min Length**. A **Max Lenght** of 5 will allow a value of "`ABCDE`" but will not allow values like "`ABCDEF`". A **Min Length** of 3 will allow a value of "`ABC`" but not allow a value of "`AB`".
Similarly, you can specify a **Max Length** and / or a **Min Length**. A **Max Length** of 5 will allow a value of "`ABCDE`" but will not allow values like "`ABCDEF`". A **Min Length** of 3 will allow a value of "`ABC`" but not allow a value of "`AB`".

Note that it is also possible to achieve the same effect by specifying a **Pattern**, such as "`.{3}`", however, the **Length** restriction is simpler and quicker to compute.
Note that it is also possible to achieve the same effect by specifying a **Pattern**: "`.{3}`" corresponds to an exact length of 3, and "`.{3,5}`" corresponds to a **Min Length** of 3 combined with a **Max Length** of 5. However, the **Length** restriction is simpler and quicker to compute.
Loading