Describes a particular set of constraints for an Attribute. Primarily, this restricts the
type of data allowed, as implied by the
type
field. A
binary-constraints
type constraint implies that all values stored for the
related Attribute must also be
binary data, not any other type.
Each particular type of constraint (for a corresponding data type) defines the set of
additional type-specific constraint parameters. For example, numeric types
often support a minimum and/or maximum numeric value; these limits would not make sense
on a binary or text data value, however.
Fields
type
string
|
Indicates the specific type of constraints represented by this object.
0.6
valid values:
binary-constraints
decimal-constraints
integer-constraints
percent-constraints
text-constraints
datetime-constraints
date-constraints
|
min
decimal
|
Specifies the minimum (inclusive) allowable numeric value, supported when
type is one of:
- integer-constraints
- decimal-constraints
- percent-constraints
- datetime-constraints
- date-constraints
For the datetime-constraints and date-constraints type,
the value must be a String representing a valid ISO-8601 datetime/date
that is no larger than -1000000000-01-01T00:00Z and -999999999-01-01 respectively.
For the integer-constraints type, the value must be a signed integer
(no fractional value). For all other types, the value may be any signed decimal.
Percentage values must use the machine-friendly scale where "12%" is represented as:
0.12
If also defining a max constraint, this value must be less than or equal
to the defined maximum value.
|
max
decimal
|
Specifies the maximum (inclusive) allowable numeric value, supported when
type is one of:
- integer-constraints
- decimal-constraints
- percent-constraints
- datetime-constraints
- date-constraints
For the datetime-constraints and date-constraints type,
the value must be a String representing a valid ISO-8601
datetime/date that is no larger than 1000000000-12-31T23:59:59.999999999Z and
+999999999-12-31 respectively.
For the integer-constraints type, the value must be a signed integer
(no fractional value). For all other types, the value may be any signed decimal.
Percentage values must use the machine-friendly scale where "12%" is represented as:
0.12
If also defining a min constraint, this value must be greater than or equal
to the defined minimum value.
|
minLength
int32
|
Specifies the minimum length (inclusive), in characters, and is supported when
type is: text-constraints
The length of a given text value is defined as the number of quad-octet groups
required to represent the text value in UTF-16 encoding. This may differ from
the number of visible characters displayed.
If also defining a maxLength constraint, this value must be less than
or equal to the defined maximum length. In all cases, this value must be ≥ 0.
|
maxLength
int32
|
Specifies the maximum length (inclusive), in characters, and is supported when
type is: text-constraints
The length of a given text value is defined as the number of quad-octet groups
required to represent the text value in UTF-16 encoding. This may differ from
the number of visible characters displayed.
If also defining a minLength constraint, this value must be greater than
or equal to the defined minimum length.
|
maxBytes
int32
|
Specifies the maximum (inclusive) size of the binary data, in octets exclusive of
any encodings, and is supported when type is: binary-constraints
A binary value encoded in Hex generally requires twice the number of bytes as
used in the unencoded binary data. The same value encoded in Base-64 requires
4⁄3 of the original, unencoded byte length (or just
33% overhead). This constraint does not apply to the encoded format (though
other restrictions may effectively limit the transmissible length of the encoded
format) and only considers the length of the unencoded bytes after decoding.
|
Example
- constraints for text (non-localized)
{
"type" :"text-constraints",
"minLength" :1,
"maxLength" :256
}
Example
- constraints for binary data
{
"type" :"binary-constraints",
"maxBytes" :1048576
}
Example
- constraints for integers
{
"type" :"integer-constraints",
"min" :-42
"max" :42
}
Example
- constraints for decimals
{
"type" :"decimal-constraints",
"min" :-2.71828
"max" :3.14159
}
Example
- constraints for percents
{
"type" :"percent-constraints",
"min" :-0.1
"max" :1.10
}
Example
- constraints for datetime
{
"type" :"datetime-constraints",
"min" :"2000-12-03T10:15:30Z"
"max" :"2020-12-03T10:15:30Z"
}
Example
- constraints for date
{
"type" :"date-constraints",
"min" :"2000-12-03"
"max" :"2020-12-03"
}