Hide Comments

Constraints define the domain of legal values for a Simple Type, a Primitive Property, or a Primitive Property Realization. There are four types of Constraint: numeric value range, string fixed length, string length, and regular expression.

Syntax

Numeric value range constraint

[~with] valueRange from [~minimum] <min-value> [inclusive | exclusive] [~up] to [~maximum] <max-value> [inclusive | exclusive]

String fixed length constraint

[~of] length <fixed-length>

String length constraint

[~of] length [from [~minimum] <min-length>] [[~up] to [~maximum] <max-length>]

String regular expression constraint

[~matching] regex r"<regular-expression>"

Examples

// Integer value range constraint applied to Built-in int type property within structure definition

structure TaxFiling

dayOfYear : int

with valueRange from minimum 1 inclusive up to maximum 366 inclusive

 

// String fixed length constraint applied to User-defined Simple Type

simpleType CurrencyCode defined as string

of length 3

 

// String length constraint applied to a User-defined Simple Type

simpleType UserName defined as string

of length from minimum 6 up to maximum 12

 

// String regular expression constraint applied to Built-in structure property in Realization property set

objectResource PersonObject type Person

URI people/{id}

with all properties including

ssn

matching regex r"(?!000|666)[0-8][0-9]{2}-(?!00)[0-9]{2}-(?!0000)[0-9]{4}"

Parameters

Numeric Value Range Constraint

Field Name

Type

Description

<min-value>

number

The lower bound of the value range, specified as an integer or decimal number.

<max-value>

number

The upper bound of the value range, specified as an integer or decimal number.

inclusive

keyword

Indicates that the value range includes the preceding <min-value> or <max-value>.  Upper and lower bounds are inclusive by default. The inclusive keyword is provided only for readability.

exclusive

keyword

Indicates that the value range excludes the preceding <min-value> or <max-value>.

String Fixed Length Constraint

Field Name

Type

Description

<fixed-length>

integer

The required length of the string, specified as a non-negative integer.  A string value is valid only if its length matches this value exactly.

String Length Constraint

Field Name

Type

Description

<min-length>

integer

The minimum legal length for this string, specified as a non-negative integer.

<max-length>

integer

The maximum legal length for this string, specified as a non-negative integer.

String Regular Expression Constraint

Field Name

Type

Description

<regular-expression>

string

A regular expression which the string value must match.  Since regular expressions often contain backslashes and other special characters, raw string literal syntax is recommended.  See the Discussion below.

Child Elements

None.

Parent Elements

Simple Type
Primitive Property (excluding Enumeration)
Property Set (within a Primitive Property realization)

Discussion

String Length Sub-Constraints

The String Length Constraint allows minimum length and maximum length sub-constraints.  A valid string length Constraint MUST specify at least one of these two sub-constraints, and MAY specify both.

Regular Expression Syntax

RAPID-ML supports the subset of the ECMA 262 regular expression dialect recommended in the JSON Schema specification.

Note that beginning- and end-of-string anchors are implicitly defined.  Explicit anchors are disallowed in RAPID-ML regular expressions.

Raw Strings

String literals in RAPID-ML may be specified as normal strings or raw strings.  Normal string literals are delimited by single or double quotes, and support standard escape sequences.  Raw string literals use the form r"<string>" - a lower-case 'r' followed by a double-quoted string.  Raw strings are not escaped, so backslashes and other special characters are treated literally.

For this reason, raw string literals are recommended for regular expression strings.

Created with Help & Manual 6 and styled with Premium Pack Version 2.51 © by EC Software