Changeset 2333

Show
Ignore:
Timestamp:
06/23/09 20:45:18 (13 months ago)
Author:
lmajano
Message:

Validator plugin

Location:
coldbox/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • coldbox/trunk/system/plugins/Validator.cfc

    r2332 r2333  
    1010        An incredible validator for all the following: 
    1111         
    12 Validations (Can be a list): 
     12Validations: 
    1313- boolean 
    1414- date 
     
    2727- string 
    2828- telephone 
    29 - udf-{UDF Method} 
    3029- URL 
    3130- uuid 
     
    108107                function checkTelephone(str){ return isValid("telephone",arguments.str); } 
    109108                 
    110                 function checkWithUDF(str,udf){ 
    111                         var udfCall = arguments.udf; 
    112                         return udfCall(arguments.str); 
    113                 } 
    114                  
    115109                function checkURL(str){ return isValid("URL",arguments.str); } 
    116110                 
  • coldbox/trunk/testing/cases/plugins/ValidatorTest.cfc

    r2332 r2333  
    88Date        :   06/18/2009 
    99Description : 
    10         An incredible validatoridator for all the following: 
    11          
    12 validatoridations (Can be a list): 
    13 - boolean 
    14 - date 
    15 - email 
    16 - eurodate 
    17 - exactLen-X 
    18 - numeric or float 
    19 - guid 
    20 - integer 
    21 - maxLen-X 
    22 - minLen-X 
    23 - range-1..4 
    24 - regex-{regexhere} 
    25 - sameAs-{fieldname} 
    26 - ssn 
    27 - string 
    28 - telephone 
    29 - udf-{UDF Method} 
    30 - URL 
    31 - uuid 
    32 - USdate: a U.S. date of the format mm/dd/yy, with 1-2 digit days and months, 1-4 digit years.  
    33 - zipcode 5 or 9 digit format zip codes 
    34  
     10Test 
    3511-----------------------------------------------------------------------> 
    3612<cfcomponent extends="coldbox.system.testing.BaseTestCase"> 
     
    135111        } 
    136112         
    137         function testcheckWithUDF(){ 
    138                 assertTrue( validator.checkWithUDF(true,variables.myUDF) ); 
    139                 assertFalse(validator.checkWithUDF('2342-asb',variables.myUDF) ); 
    140         } 
    141          
    142113        function testcheckURL(){ 
    143114                assertTrue( validator.checkURL('http://www.coldbox.org') ); 
     
    165136        }        
    166137</cfscript> 
    167  
    168 <cffunction name="myUDF" access="private" returntype="boolean"> 
    169         <cfargument name="str" type="string" required="true" default="" hint=""/> 
    170         <cfreturn isBoolean(arguments.str)> 
    171 </cffunction> 
    172138</cfcomponent>