Skip to content

String Length Validation

The String Length Validation rule ensures string values adhere to defined length constraints.
This rule is commonly used to:

  • Validate fixed-length identifiers like phone numbers or country codes
  • Enforce minimum/maximum length requirements for address fields, codes, etc.
  • Ensure consistent data entry standards

Example Usage:

  • Verify all country codes are exactly 2 characters long (like “IN”, “US”)
  • Ensure phone numbers are between 10-15 digits after trimming
  • Validate access tokens have a minimum of 32 characters

Configuration Fields

Rule-Specific Configuration

Field NameDescriptionRequiredData Type / Options
Minimum LengthMinimum allowed lengthNoInteger
Maximum LengthMaximum allowed lengthNoInteger
Exact LengthRequired exact lengthNoInteger
Left TrimTrim whitespace from start of stringNotrue / false (default: true)
Right TrimTrim whitespace from end of stringNotrue / false (default: true)
Consider WhitespaceInclude whitespace characters in length calculationNotrue / false (default: false)

Success Criteria Configuration

This section defines how the rule’s outcome is measured against expected thresholds.

Field NameDescriptionRequiredOptions / Format
OperatorComparison operation for the result countYesGreaterThan, LessThan, EqualTo, Between
Threshold ValueValue for comparison (single value for most operators)ConditionalNumber
Threshold MinMinimum value (for Between operator)ConditionalNumber
Threshold MaxMaximum value (for Between operator)ConditionalNumber
Is PercentageWhether the threshold represents a percentage or countNotrue / false (default: false)
Allow NullsShould null values be treated as validNotrue / false (default: false)
Check For MatchWhen false, validates for negation of the conditionNotrue / false (default: true)

Sample Input Data

UserIDCountryCodePhoneNumber
1IN9876543210
2US11234567890
3UK447890123456
4IN98765 43210
5nullnull

Sample Configurations

Example 1: Country Code Exact Length

Configuration FieldValue
ColumnCountryCode
Exact Length2
OperatorGreaterThan
Threshold Value4
Is Percentagefalse
Allow Nullsfalse
Check For Matchtrue

Explanation:
Ensures that at least 4 country codes are exactly 2 characters long (e.g., “IN”, “US”).


Example 2: Phone Number Length Range

Configuration FieldValue
ColumnPhoneNumber
Minimum Length10
Maximum Length15
Left Trimtrue
Right Trimtrue
OperatorGreaterThan
Threshold Value4
Is Percentagefalse
Allow Nullsfalse
Check For Matchtrue

Explanation:
Validates that at least 4 phone numbers have lengths between 10 and 15 characters (after trimming), ensuring basic phone number formatting.


Sample Output

Column NameRule NameSuccess CountFailure CountNull CountWithin Threshold
CountryCodeString Length Validation401Yes
PhoneNumberString Length Validation401Yes