Packagesekati.validators
Classpublic class TypeValidator

Basic Type Validation



Public Methods
 MethodDefined by
  
TypeValidator Static Constructor
TypeValidator
  
compare(o1:*, o2:*):Boolean
[static] Compares the types of two objects.
TypeValidator
  
isBoolean(str:String):Boolean
[static] Check if the passed-in string is a Boolean.
TypeValidator
  
isExplicitInstanceOf(o:*, c:*):Boolean
[static] Checks if the passed-in object is an explicit instance of the passed-in class.
TypeValidator
  
isGenericObject(o:*):Boolean
[static] Checks if the passed-in object is a generic object.
TypeValidator
  
isHex(str:String):Boolean
[static] Check if the passed-in string is an hexidecimal value.
TypeValidator
  
isInstanceOf(o:*, type:*):Boolean
[static] Checks if the passed-in object is an instance of the passed-in type.
TypeValidator
  
isNumber(str:String):Boolean
[static] Check if the passed-in string is a Number.
TypeValidator
  
isOctal(str:String):Boolean
[static] Check if the passed-in string is an octal value.
TypeValidator
  
isPassedByReference(o:*):Boolean
[static] Checks if a class instance is a non-primitive type which will be copied by reference (e.g.
TypeValidator
  
isPassedByValue(o:*):Boolean
[static] Checks if a class instance is a primitive type which will be copied by value (e.g.
TypeValidator
  
isPrimitive(o:*):Boolean
[static] Checks if the passed-in object is a primitive type.
TypeValidator
  
isTypeOf(o:*, type:String):Boolean
[static] Checks if the result of an execution of the typeof method on the passed-in object matches the passed-in type.
TypeValidator
  
strictIs(instance:Object, compareClass:Class):Boolean
[static] Checks the class of instance against the compareClass for strict equality.
TypeValidator
  
typesMatch(o:*, type:*):Boolean
[static] Checks if the type of the passed-in object matches the passed-in type.
TypeValidator
Public Constants
 ConstantDefined by
  BOOLEAN : String = "boolean"
[static]
TypeValidator
  DATE : String = "date"
[static]
TypeValidator
  ERROR : String = "error"
[static]
TypeValidator
  FUNCTION : String = "function"
[static]
TypeValidator
  INT : String = "int"
[static]
TypeValidator
  NULL : String = "null"
[static]
TypeValidator
  NUMBER : String = "number"
[static]
TypeValidator
  OBJECT : String = "object"
[static]
TypeValidator
  STRING : String = "string"
[static]
TypeValidator
  UINT : String = "uint"
[static]
TypeValidator
  UNDEFINED : String = "undefined"
[static]
TypeValidator
  XML : String = "xml"
[static]
TypeValidator
Protected Constants
 ConstantDefined by
  IS_BOOLEAN : RegExp
[static]
TypeValidator
  IS_HEX : RegExp
[static]
TypeValidator
  IS_NUMBER : RegExp
[static]
TypeValidator
  IS_OCTAL : RegExp
[static]
TypeValidator
Constructor detail
TypeValidator()constructor
public function TypeValidator()

TypeValidator Static Constructor

Method detail
compare()method
public static function compare(o1:*, o2:*):Boolean

Compares the types of two objects.

Parameters
o1:*
 
o2:*

Returns
Booleantrue if the two objects are the same primitive type.
isBoolean()method 
public static function isBoolean(str:String):Boolean

Check if the passed-in string is a Boolean.

Parameters
str:String

Returns
Booleantrue if the passed-in object is a Boolean.

See also

isExplicitInstanceOf()method 
public static function isExplicitInstanceOf(o:*, c:*):Boolean

Checks if the passed-in object is an explicit instance of the passed-in class.

Parameters
o:*
 
c:*

Returns
Booleantrue if the passed-in object is an explicit instance of the passed-in class.
isGenericObject()method 
public static function isGenericObject(o:*):Boolean

Checks if the passed-in object is a generic object.

Parameters
o:*

Returns
Booleantrue if the passed-in object is a generic object.
isHex()method 
public static function isHex(str:String):Boolean

Check if the passed-in string is an hexidecimal value.

Parameters
str:String

Returns
Booleantrue if the passed-in object is a hexidecimal value.
isInstanceOf()method 
public static function isInstanceOf(o:*, type:*):Boolean

Checks if the passed-in object is an instance of the passed-in type.

Parameters
o:*
 
type:*

Returns
Booleantrue if the passed-in object is an instance of the passed-in type.
isNumber()method 
public static function isNumber(str:String):Boolean

Check if the passed-in string is a Number.

Parameters
str:String

Returns
Booleantrue if the passed-in object is a Number.
isOctal()method 
public static function isOctal(str:String):Boolean

Check if the passed-in string is an octal value.

Parameters
str:String

Returns
Booleantrue if the passed-in object is a octal value.
isPassedByReference()method 
public static function isPassedByReference(o:*):Boolean

Checks if a class instance is a non-primitive type which will be copied by reference (e.g. a pointer to the existing object) or by value (e.g. a new object).

Parameters
o:* — - the object to be validated

Returns
Booleantrue if instance is not a primitive value or is null.
isPassedByValue()method 
public static function isPassedByValue(o:*):Boolean

Checks if a class instance is a primitive type which will be copied by value (e.g. a new object) or by reference (pointer).

Parameters
o:* — - the object to be validated

Returns
Booleantrue if instance is a primitive value & not null.
isPrimitive()method 
public static function isPrimitive(o:*):Boolean

Checks if the passed-in object is a primitive type.

Parameters
o:*

Returns
Booleantrue if the passed-in object is a primitive type.
isTypeOf()method 
public static function isTypeOf(o:*, type:String):Boolean

Checks if the result of an execution of the typeof method on the passed-in object matches the passed-in type.

Parameters
o:*
 
type:String

Returns
Booleantrue if the result of an execution of the typeof method on the passed-in object matches the passed-in type.
strictIs()method 
public static function strictIs(instance:Object, compareClass:Class):Boolean

Checks the class of instance against the compareClass for strict equality. If the classes are exactly the same, returns true. If the classes are different even if the instance's class is a subclass of compareClass, it returns false. Does not work with interfaces. The compareClass must be a class.

Parameters
instance:Object — - the object whos class you want to check.
 
compareClass:Class — - the class to compare your object against.

Returns
Boolean — true if instance is strictly of type compareClass.

Example
   var myBase:BaseClass = new BaseClass();
   var mySub:SubClass = new SubClass();
   trace(strictIs(myBase, BaseClass));   // true
   trace(strictIs(mySub, SubClass));        // true
   trace(strictIs(mySub, BaseClass));       // false
   

typesMatch()method 
public static function typesMatch(o:*, type:*):Boolean

Checks if the type of the passed-in object matches the passed-in type.

Parameters
o:*
 
type:*

Returns
Boolean

Example
   import sekati.validate.TypeValidation;
   var s1:String = "hello world";
   var s2:String = new String("hello world");
   trace("s1 is string : " + TypeValidation.typesMatch( s1, String )); // output : 'true'
   trace("s2 is string : " + TypeValidation.typesMatch( s2, String )); // output : 'true'
   

Constant detail
BOOLEANconstant
public static const BOOLEAN:String = "boolean"
DATEconstant 
public static const DATE:String = "date"
ERRORconstant 
public static const ERROR:String = "error"
FUNCTIONconstant 
public static const FUNCTION:String = "function"
INTconstant 
public static const INT:String = "int"
IS_BOOLEANconstant 
protected static const IS_BOOLEAN:RegExp
IS_HEXconstant 
protected static const IS_HEX:RegExp
IS_NUMBERconstant 
protected static const IS_NUMBER:RegExp
IS_OCTALconstant 
protected static const IS_OCTAL:RegExp
NULLconstant 
public static const NULL:String = "null"
NUMBERconstant 
public static const NUMBER:String = "number"
OBJECTconstant 
public static const OBJECT:String = "object"
STRINGconstant 
public static const STRING:String = "string"
UINTconstant 
public static const UINT:String = "uint"
UNDEFINEDconstant 
public static const UNDEFINED:String = "undefined"
XMLconstant 
public static const XML:String = "xml"