Validating form data

In some cases, such as the telephone number, it does not make sense to specify a mask without a pattern, but you may want to specify a pattern without a mask.Likewise, using a pattern with the uppercase mask is not necessary.This can be somewhat confusing, but is the only effective way of specifying them.You can specify both a pattern and input mask or only one of them.It may legitimately be entered in a number of patterns, such as (513) 529-1809, 513.529.1809 or 513-529-1809.However, for consistency, the telephone number should always be stored as (513) 529-1809 in the database.Since this is an item of type "numeric," it is automatically validated as a number.The validate rules "required:max=4:min=0" specify that the element is required and must be between 0 and 4. However, if multiple rules are applied to an element, the validation process will throw a warning on the first violation and stop processing that element.

The implementation of pattern matching and input masks are combined in one validation rule because they are intricately tied together.The entire value must be represented by the pattern or the validation will fail.A mask may also be provided to cause the data to be returned in a specific format.The type of data determines what rules are applicable and how the validation behaves.Many rules support a limit value to use as a comparison.

Leave a Reply