Package | com.cyntaxic.cyntils |
Class | public class CynValidate |
Inheritance | CynValidate Object |
CynValidate
class contains static functions for
validation. Each function can return true or false, or if passFail
is set to false a result object containing valid
, code
and text
properties is returned. Validiation codes returned by the result
object are enumerated in the class.
Property | Defined By | ||
---|---|---|---|
passFail : Boolean = true [static]
Flag to determine whether true of false is returned or a result object. | CynValidate |
Method | Defined By | ||
---|---|---|---|
alphaNumeric(value:String):Boolean [static]
Determines whether the string contains only alphanumeric characters. | CynValidate | ||
date(value:String, dayFirst:Boolean = false):Object [static]
Determines if the string contains a valid date. | CynValidate | ||
digit(value:String):Boolean [static]
Casts a string as a number. | CynValidate | ||
email(value:String):Object [static]
Determines whether a string is an email address. | CynValidate | ||
eq(a:*, b:*, strict:Boolean = false):Boolean [static]
Tests to see if two objects are equal. | CynValidate | ||
integerInRange(value:String, min:int, max:int):Boolean [static]
Determines whether the integer with a specified range. | CynValidate | ||
ip(value:String):Object [static]
Determine whether a string is a valid IP address. | CynValidate | ||
letter(value:String):Boolean [static]
Determines if the character is within A-Z or a-z. | CynValidate | ||
letterOrDigit(value:String):Boolean [static]
Determines whether the character is a letter or a number. | CynValidate | ||
notEmpty(value:String, white:Boolean = false):Boolean [static]
Determines whether the string contains data. | CynValidate | ||
socialSecurity(value:String):Object [static]
Checks to see if the string is a valid Social Security Number. | CynValidate | ||
uneq(a:*, b:*, strict:Boolean = false):Boolean [static]
Tests to see if two objects are not equal. | CynValidate | ||
url(value:String, ssl:Boolean = false):Object [static]
Performs basic checks to determine if a string is a valid HTTP or HTTPS URL. | CynValidate | ||
urlSecure(value:String):Object [static]
Performs basic checks to determine if a string is a valid HTTPS URL. | CynValidate | ||
validChars(value:String, chars:String):Boolean [static]
Compare a string against a list of characters to determine if the string contains
only those characters. | CynValidate | ||
worldDate(value:String):Object [static]
Determines whether the string contains a valid day-first format date. | CynValidate |
Constant | Defined By | ||
---|---|---|---|
DATE_CANT_CONVERT_TO_DATE : int = 2006 [static]
Code for an error in conversion to date. | CynValidate | ||
DATE_DAY_OUT_OF_RANGE : int = 2002 [static]
Code for the day being out of range. | CynValidate | ||
DATE_INCORRECT_FORMAT : int = 2003 [static]
Code for date being in incorrect format. | CynValidate | ||
DATE_INCORRECT_YEAR : int = 2005 [static]
Code for an incorrect year. | CynValidate | ||
DATE_MONTH_OUT_OF_RANGE : int = 2001 [static]
Code for date of the month being out of range. | CynValidate | ||
DATE_TOO_MANY_SEPARATORS : int = 2004 [static]
Code for too many separators in a date. | CynValidate | ||
EMAIL_CAN_HAVE_1_AT_SIGN : int = 2017 [static]
Code for email having more than one @ sign. | CynValidate | ||
EMAIL_INVALID_CHARS : int = 2016 [static]
Code for an email having invalid characters. | CynValidate | ||
EMAIL_INVALID_DOMAIN : int = 2019 [static]
Code for an email with an invalid domain. | CynValidate | ||
EMAIL_INVALID_DOMAIN_EXT : int = 2020 [static]
Code for an email with an invalid extension. | CynValidate | ||
EMAIL_USERNAME_BLANK : int = 2018 [static]
Code for an email with a blank username. | CynValidate | ||
IP_CONTAINS_INVALID_CHARS : int = 2007 [static]
Code for invalid characters in an IP address. | CynValidate | ||
IP_FIRST_VALUE_ZERO : int = 2009 [static]
Code for first value in an IP being zero. | CynValidate | ||
IP_INCORRECT_PERIODS : int = 2008 [static]
Code for incorrect number of periods in an IP address. | CynValidate | ||
IP_PART_NOT_VALID_NUM : int = 2010 [static]
Code for IP being not a valid number. | CynValidate | ||
SSN_INVALID_CHARS : int = 2021 [static]
Code for a social security number with invalid characters. | CynValidate | ||
SSN_INVALID_FORMAT : int = 2022 [static]
Code for a social security number with an invalid format. | CynValidate | ||
SSN_TOO_MANY_DASHES : int = 2023 [static]
Code for a social security number with too many dashes. | CynValidate | ||
SSN_WRONG_LENGTH : int = 2024 [static]
Code for a social security number that is too long. | CynValidate | ||
URL_CAN_HAVE_1_QUESTION_MARK : int = 2015 [static]
Code for a URL having more than one question mark. | CynValidate | ||
URL_INVALID_CHARS : int = 2013 [static]
Code for a URL having invalid characters. | CynValidate | ||
URL_INVALID_DOMAIN_NAME : int = 2014 [static]
Code for an invalid domain name. | CynValidate | ||
URL_INVALID_PROTOCOL : int = 2012 [static]
Code for a URL being an invalid protocol. | CynValidate | ||
URL_LENGTH_INVALID : int = 2011 [static]
Code for a URL being an invalid length. | CynValidate | ||
VALID : int = 2000 [static]
Code for valid. | CynValidate |
passFail | property |
public static var passFail:Boolean = true
Flag to determine whether true of false is returned or a result object. Default is true. Switch to false to return a result object containing valid, code and text properties if the validation is more complex than true or false.
alphaNumeric | () | method |
public static function alphaNumeric(value:String):Boolean
Determines whether the string contains only alphanumeric characters.
Parameters
value:String — The string to validate.
|
Boolean — True if the data is valid.
|
date | () | method |
public static function date(value:String, dayFirst:Boolean = false):Object
Determines if the string contains a valid date. Valid examples include 9/30/09, 9-30-09 or 9.30.09.
Parameters
value:String — The String containing the date.
| |
dayFirst:Boolean (default = false ) — Whether the date is in a day first format.
|
Object — True, false or a result object.
|
digit | () | method |
public static function digit(value:String):Boolean
Casts a string as a number. If it fails, returns false.
Parameters
value:String — The String of the number to validate.
|
Boolean — True if the data is valid.
|
() | method |
public static function email(value:String):Object
Determines whether a string is an email address. Checks for common email address formats but it does not support the full RFC definition.
Parameters
value:String — The string containing the email address.
|
Object — True, false or a result object.
|
eq | () | method |
public static function eq(a:*, b:*, strict:Boolean = false):Boolean
Tests to see if two objects are equal. If strict is set, then it is tested strictly with strict equality instead of just the equality operator.
Parameters
a:* — The object.
| |
b:* — The compare object.
| |
strict:Boolean (default = false ) — Flag to decide whether to test strictly.
|
Boolean — True if the same.
|
integerInRange | () | method |
public static function integerInRange(value:String, min:int, max:int):Boolean
Determines whether the integer with a specified range.
Parameters
value:String — The string representing the number to validate.
| |
min:int — The minimum value as a number (>= comparison).
| |
max:int — The maxium value as a number (<= comparison).
|
Boolean — True if the data is within the range.
|
ip | () | method |
public static function ip(value:String):Object
Determine whether a string is a valid IP address.
Parameters
value:String — The string containing the IP address.
|
Object — True, false or a result object.
|
letter | () | method |
public static function letter(value:String):Boolean
Determines if the character is within A-Z or a-z.
Parameters
value:String — The character to validate.
|
Boolean — True if the data is valid.
|
letterOrDigit | () | method |
public static function letterOrDigit(value:String):Boolean
Determines whether the character is a letter or a number.
Parameters
value:String — The character to validate.
|
Boolean — True if the data is valid.
|
notEmpty | () | method |
public static function notEmpty(value:String, white:Boolean = false):Boolean
Determines whether the string contains data.
Parameters
value:String — The character to validate.
| |
white:Boolean (default = false ) — A boolean when set to false will ignore white space (space, newline, tab).
|
Boolean — True if the string is not empty.
|
socialSecurity | () | method |
public static function socialSecurity(value:String):Object
Checks to see if the string is a valid Social Security Number. Valid examples are 111-11-1111 or 111111111.
Parameters
value:String — The string that will be validated.
|
Object — True, false or a result object.
|
uneq | () | method |
public static function uneq(a:*, b:*, strict:Boolean = false):Boolean
Tests to see if two objects are not equal. If strict is set, then it is tested strictly with strict equality instead of just the equality operator.
Parameters
a:* — The object.
| |
b:* — The compare object.
| |
strict:Boolean (default = false ) — Flag to decide whether to test strictly.
|
Boolean — True if different.
|
url | () | method |
public static function url(value:String, ssl:Boolean = false):Object
Performs basic checks to determine if a string is a valid HTTP or HTTPS URL.
Parameters
value:String — The string containing the URL.
| |
ssl:Boolean (default = false ) — A boolean value that is set to true for HTTPS URL.
|
Object — True, false or a result object.
|
urlSecure | () | method |
public static function urlSecure(value:String):Object
Performs basic checks to determine if a string is a valid HTTPS URL.
Parameters
value:String — The string containing the HTTPS URL.
|
Object — True, false or a result object.
|
validChars | () | method |
public static function validChars(value:String, chars:String):Boolean
Compare a string against a list of characters to determine if the string contains only those characters. This comparison is not case-sensitive and does not validate the order of the characters.
Parameters
value:String — The string that needs to be validated.
| |
chars:String — The list of valid characters for that string.
|
Boolean — True if the data is valid.
|
worldDate | () | method |
public static function worldDate(value:String):Object
Determines whether the string contains a valid day-first format date.
Parameters
value:String — The string containing a date in a day-first format.
|
Object — True if the date is a valid day-first date.
|
DATE_CANT_CONVERT_TO_DATE | Constant |
public static const DATE_CANT_CONVERT_TO_DATE:int = 2006
Code for an error in conversion to date.
DATE_DAY_OUT_OF_RANGE | Constant |
public static const DATE_DAY_OUT_OF_RANGE:int = 2002
Code for the day being out of range.
DATE_INCORRECT_FORMAT | Constant |
public static const DATE_INCORRECT_FORMAT:int = 2003
Code for date being in incorrect format.
DATE_INCORRECT_YEAR | Constant |
public static const DATE_INCORRECT_YEAR:int = 2005
Code for an incorrect year.
DATE_MONTH_OUT_OF_RANGE | Constant |
public static const DATE_MONTH_OUT_OF_RANGE:int = 2001
Code for date of the month being out of range.
DATE_TOO_MANY_SEPARATORS | Constant |
public static const DATE_TOO_MANY_SEPARATORS:int = 2004
Code for too many separators in a date.
EMAIL_CAN_HAVE_1_AT_SIGN | Constant |
public static const EMAIL_CAN_HAVE_1_AT_SIGN:int = 2017
Code for email having more than one @ sign.
EMAIL_INVALID_CHARS | Constant |
public static const EMAIL_INVALID_CHARS:int = 2016
Code for an email having invalid characters.
EMAIL_INVALID_DOMAIN | Constant |
public static const EMAIL_INVALID_DOMAIN:int = 2019
Code for an email with an invalid domain.
EMAIL_INVALID_DOMAIN_EXT | Constant |
public static const EMAIL_INVALID_DOMAIN_EXT:int = 2020
Code for an email with an invalid extension.
EMAIL_USERNAME_BLANK | Constant |
public static const EMAIL_USERNAME_BLANK:int = 2018
Code for an email with a blank username.
IP_CONTAINS_INVALID_CHARS | Constant |
public static const IP_CONTAINS_INVALID_CHARS:int = 2007
Code for invalid characters in an IP address.
IP_FIRST_VALUE_ZERO | Constant |
public static const IP_FIRST_VALUE_ZERO:int = 2009
Code for first value in an IP being zero.
IP_INCORRECT_PERIODS | Constant |
public static const IP_INCORRECT_PERIODS:int = 2008
Code for incorrect number of periods in an IP address.
IP_PART_NOT_VALID_NUM | Constant |
public static const IP_PART_NOT_VALID_NUM:int = 2010
Code for IP being not a valid number.
SSN_INVALID_CHARS | Constant |
public static const SSN_INVALID_CHARS:int = 2021
Code for a social security number with invalid characters.
SSN_INVALID_FORMAT | Constant |
public static const SSN_INVALID_FORMAT:int = 2022
Code for a social security number with an invalid format.
SSN_TOO_MANY_DASHES | Constant |
public static const SSN_TOO_MANY_DASHES:int = 2023
Code for a social security number with too many dashes.
SSN_WRONG_LENGTH | Constant |
public static const SSN_WRONG_LENGTH:int = 2024
Code for a social security number that is too long.
URL_CAN_HAVE_1_QUESTION_MARK | Constant |
public static const URL_CAN_HAVE_1_QUESTION_MARK:int = 2015
Code for a URL having more than one question mark.
URL_INVALID_CHARS | Constant |
public static const URL_INVALID_CHARS:int = 2013
Code for a URL having invalid characters.
URL_INVALID_DOMAIN_NAME | Constant |
public static const URL_INVALID_DOMAIN_NAME:int = 2014
Code for an invalid domain name.
URL_INVALID_PROTOCOL | Constant |
public static const URL_INVALID_PROTOCOL:int = 2012
Code for a URL being an invalid protocol.
URL_LENGTH_INVALID | Constant |
public static const URL_LENGTH_INVALID:int = 2011
Code for a URL being an invalid length.
VALID | Constant |
public static const VALID:int = 2000
Code for valid.