The main purpose of constraints is to alter the default behavior of a data type and to clearly set the accepted limits and behavioral directions. The meta-data that's provided through constraints can be used elsewhere to gather more information about how to correctly integrate the additional information.
For example, a constraint specifies that a certain text's length is limited to 30 characters, parts of the system can query this information and act accordingly:
- a HTML form builder can create a field that doesn't allow the entry of longer text,
- a SQL query builder can limit the size of the column in which the text will stored when the table creation SQL is generated,
- a validation system can check if the text isn't longer than 30 characters and provide appropriate information when the length is exceeded.
A large collection of constraints are available and are thoroughly integrated throughout the entire framework.