When we use a string validator in Flex, it just checks for the minimum and Maximum length. There was a requirement to have a validator which could check the validity of the string based on special characters, numbers and spaces. This component seeks to address this problem.
The solution lies in the Advanced String Validator which can validate the string based on whether numerals, spaces and special characters may be allowed in the string.
When using the built-in string validator, the developer can only check for the validity of the string based on minimum and the maximum length. However, when we were creating forms to accept data from the user, some of the fields were not allowed to accept special characters or numerals or spaces.
In this case, one had to write a long wound method in the action script to check for spaces, special characters, numerals, etc. This component extends the functionalities of a string validator to allow the developer to decide if special characters, numerals or spaces may be a part of the string or not. Based on the developer's settings, the validator will provide an error balloon like a normal validator. Also the error messages displayed in the error balloon when the string constraints are not adhered to can be customised by the developer using the provided properties.
AdvancedStringValidator introduces the following properties :
allowNumbers - Boolean - set to true if the developer wants numerals to be a part of the string
allowSpaces - Boolean - set to true if the developer wants spaces to be a part of the string
allowSpecialCharacters - Boolean - set to true if the developer wants special characters to be a part of the string
numeralNotAllowedError - String - Error method displayed if allowNumbers is set to false and a numeral is included in the string
spaceNotAllowedError - String - Error method displayed if allowSpaces is set to false and a space is included in the string
specialCharacterNotAllowedError - String - Error method displayed if allowSpecialCharacters is set to false and a special character is included in the string