Documentation Center

Constraining field content

In the Source tab of a Schema you can add field constraints called facets to some Schema field types. Components based on schemas that use these facets can still be edited in the Content Manager Explorer.

The following sections describe the facets.

minInclusive and minExclusive

Defines lowest accepted value. minInclusive defines the lowest accepted value, whereas minExclusive defines the lowest unaccepted value. (For example, if minInclusive=1, then 1 is accepted, but 0.9999999 is not. If minExclusive=1, then 1.0 is not accepted, but 1.000001 is.) The following example is a number field that accepts a lowest value of "1".

<xsd:element name="number">
	<xsd:simpleType>
		<xsd:restriction base="xsd:decimal">
			<xsd:minInclusive value="1"/>
		</xsd:restriction> 
	</xsd:simpleType>
</xsd:element>

maxInclusive and maxExclusive

Defines the highest accepted value. maxInclusive defines the highest accepted value, whereas maxExclusive defines the highest unaccepted value. (For example, if maxInclusive=100, then 100 is accepted, but 100.1 is not. If maxExclusive=100, then 100 is not accepted, but 99.99999 is.) The following example is a number field that does not accept a highest value of "101".

<xsd:element name="number">
	<xsd:simpleType>
		<xsd:restriction base="xsd:decimal">
			<xsd:maxExclusive value="101"/>
		</xsd:restriction>
	</xsd:simpleType>
</xsd:element>

totalDigits

Defines the maximum number of digits in a number field. The facet value must be a positive integer. The following example is a number field that accepts values up to 8 digits (For example, 98765432 is accepted, but 123456789 is not).

<xsd:element name="number">
	<xsd:simpleType>
		<xsd:restriction base="xsd:decimal">
			<xsd:totalDigits value="8"/>
		</xsd:restriction>
	</xsd:simpleType>
</xsd:element>

fractionDigits

Defines the maximum number of fractions digits. The facet value must be a positive integer. The following example is a number field that accepts less than or 2 fractional digits (For example, .89 is accepted, but .234 is not)

<xsd:element name="number">
	<xsd:simpleType>
		<xsd:restriction base="xsd:decimal">
			<xsd:fractionDigits value="2"/>
		</xsd:restriction>
	</xsd:simpleType>
</xsd:element>

Facets and field types

These facets can be applied to single-line text fields, number fields and date fields. Other Web Schema field types such as multi-line text fields, XHTML, Component links, multimedia links, and external links do not apply. The following table describes the facets that can be applied to specific field types.

NameSingle-line text fieldsNumber fieldsDate fields
minLengthyesnono
maxLength yesnono
pattern yesyesyes
minInclusive and minExclusivenoyesyes
maxInclusive and maxExclusivenoyesyes
totalDigitsnoyesno
fractionDigitsnoyesno

The following example depicts a Schema in which multiple facets are combined:

<xsd:element name="NumberFieldWithMultipleFacets">
	<xsd:simpleType>
		<xsd:restriction base="xsd:decimal">
			<xsd:totalDigits value="4"/>
			<xsd:fractionDigits value="2"/>
			<xsd:minInclusive value="10"/>
			<xsd:maxInclusive value="20"/>
		</xsd:restriction>
	</xsd:simpleType>
</xsd:element>

This describes a number field in which:

  • the total number of digits (including fraction digits) is 4
  • the total number of fraction digits is 2
  • the lowest accepted number is 10
  • and the highest accepted number is 20

As a result, the field value 12.68 and 19.9 would be accepted values, whereas, 32.5 and 10.456 would not be accepted.