# Data Field Validators

BriteLines provides field validators that can be defined when creating a field. Field validators ensure that data entered while creating a quote matches the expected pattern.

# Number Field

Data fields of type Number can be setup to use:

  • Number Range validator.
  • Decimal Places validator.

# Number Range Field Validator

The Number Range validator allows the user to set a minimum and maximum value. Based on this values the validator will then determine if the provided number is between the range.

# Error messages

While performing a quote, if the user's input value does not match the specified range then one of these errors will be shown:

  • Number must be between {minimum} and {maximum}. if value is less than minimum or greater than the maximum values specified on the field validator.
  • {field_value} is below the minimum of {min_value}. if the field validator has only minimum value set (maximum is blank) and the value is less than the minimum.
  • {field_value} is above the maximum of {max_value}. if the field validator has only maximum value set (minimum is blank) and the value is greater than the maximum.

# Examples

Field: mileage

# Example 1 - Minimum: 10, Maximum: 40

Valid values:

  • 10
  • Any value in between 10 and 40
  • 40

Invalid values:

  • Any value below 10
  • Any value greater than 40
# Example 2 - Maximum: 10000

Valid values:

  • 10000
  • Any value below 10000

Invalid values:

  • Any value greater than 10000
# Example 3 - Minimum: 500

Valid values:

  • 500
  • Any value greater than 500

Invalid values:

  • Any value below 500

# Decimal Places Field Validator

The Decimal Places validator allows the user to set a maxium decimal places value.

# Error messages

While performing a quote, if the user's input value has more decimal places than the maximum decimal places specified, the following error will be shown:

  • Can not have more than {Maximum Decimal Places} decimal places.

# Examples

Field: mileage

# Example 1 - Maximum Decimal Places: 0

Valid values:

  • 10
  • 20

Invalid values:

  • 10.1
  • 20.22
# Example 2 - Maximum Decimal Places: 2

Valid values:

  • 20
  • 20.2
  • 20.22

Invalid values:

  • 20.222
  • 20.2222

# Date Field

Data fields of type Date can be setup to use the Date Range validator.

# Relative Date Range Field Validator

The Relative Date Range validator allows the user to set Earliest Allowed Date and Last Allowed Date in years, months, or days.

# Error messages

While performing a quote, if the user's input value does not match the specified range then one of these errors will be shown:

  • Date must be between {Earliest Allowed Date} and {Last Allowed Date}. if user's entered date for a field is less than or greater than the Earliest Allowed Date and Last Allowed Date respectively.
  • {field_value} is before the minimum date of {Earliest Allowed Date}. if the field has only minimum range set (maximum is blank) and user's value for a field is less than the minimum.
  • {field_value} is after the maximum date of {Last Allowed Date}. if the field has only maximum range set (minimum is blank) and user's value for a field is greater than the maximum.

# Examples

# Example 1

If a birthday field is created with value -2 for Earliest Allowed Date and 5 for Last Allowed Date in Years tab and the rating date is 2019-05-23 then user would be able to select date between 2017-05-23 and 2024-05-23.

# Example 2

If a birthday field is created with value -2 for Earliest Allowed Date and 5 for Last Allowed Date in Months tab and the rating date is 2019-05-23 then user would be able to select date between 2019-03-23 and 2019-10-23.

# Example 3

If a birthday field is created with value -2 for Earliest Allowed Date and 5 for Last Allowed Date in Days tab and the rating date is 2019-05-23 then user would be able to select date between 2019-05-21 and 2019-05-28.

# String Field

Data fields of type String can be setup to use:

  • Length Range Field Validator
  • Regular Expression Field Validator

# Length Range Field Validator

Lengh Range validator allows the user to set a minimum and maximum number of characters that the value can have.

# Error messages

While performing a quote, if the user's input value does not match the specified range then one of these errors will be shown:

  • Length must be between {minimum} and {maximum}. if user input value length for a field is less than or greater than the minimum and maximum limits respectively.
  • Value must be exactly {minimum} characters length. if the field's minimum and maximum limits for a value's length are same and user entered value's length for a field is less than or greater than the validation value.
  • {field_value} has length below the minimum of {min_value}. if the field has only minimum limit set (maximum is blank) and user value's length for a field is less than the minimum.
  • {field_value} has length above the maximum of {max_value}. if the field has only maximum limit set (minimum is blank) and user value's length for a field is greater than the maximum.

# Example:

If fullname field has the length range validator setup with a Minimum of 5 and a Maximum of 10.

  • Robert is valid value.
  • Robert Mart is invalid value. It's 11 characters, which is more than the maximum (empty space is counted as a character too).
  • Mart is invalid value. Its 4 characters which is less than the minimum limit of 5.

# Regular Expression Field Validator

The Regular Expression validator allows the user to set a regular expression (sequence of symbols and characters used to represent a pattern) to be validated against.

To learn more about Regular Expressions you can go through the following tutorial. Regular expressions can also be tested online, just make sure to select flavor python on the left panel.

# Error messages

While performing a quote, if the user's input value does not match the specified regular expression, an error saying Format is unsupported. will be displayed.

# Examples

# Example 1

Field: email Regular Expression value: ^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$

Valid values:

  • robert@britecore.come
  • ro@br.co

Invalid values:

  • robert
  • robert@
  • robert.com
# Example 2

Field: phone number Regular Expression value: ^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$ for regex field.

Valid values:

  • (123) 456 7890 is valid value.
  • 123-456-7890 is valid value.

Invalid values:

  • 12 45 78
  • 123 456 78
  • (123) 456 78