[Jspro-cvs] jsPro validator.js,1.1,1.2
Brought to you by:
wigleys
|
From: <gat...@us...> - 2003-09-22 03:17:38
|
Update of /cvsroot/jspro/jsPro
In directory sc8-pr-cvs1:/tmp/cvs-serv13671
Modified Files:
validator.js
Log Message:
QA: updated comments; made validation methods generic so that the validation methods can be passed any datatype and still return the correct boolean value
Index: validator.js
===================================================================
RCS file: /cvsroot/jspro/jsPro/validator.js,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** validator.js 19 Sep 2003 15:44:21 -0000 1.1
--- validator.js 22 Sep 2003 03:17:34 -0000 1.2
***************
*** 20,23 ****
--- 20,24 ----
* +-------------------------------------------------------------------------+
* | Authors: Stuart Wigley <stu...@ya...> |
+ * | Randolph Fielding <gat...@ci...> |
* +-------------------------------------------------------------------------+
* $Id$
***************
*** 36,53 ****
/**
! * Test if the supplied value is a blank string or a string made up of
! * whitespaces, tabs or newline characters
*
! * @summary is a blank string
* @author Stuart Wigley
! * @version 1.0, 09/19/03
! * @interface <code>Validator.isBlankString(sValue)</code>
! * @param sValue the value to test against
! * @return true or false
* @return <code>null</code> if an exception is encountered
* @throws IllegalArgumentException
- * @throws TypeMismatchException
*/
! Validator.prototype.isBlankString = function(sValue) {
try {
--- 37,59 ----
/**
! * Determine if the specified value is an empty string or a string composed of
! * only whitespace characters.
*
! * @summary is blank string?
* @author Stuart Wigley
! * @author Randolph Fielding
! * @version 1.1, 09/21/03
! * @interface <code>Validator.isBlankString(vValue)</code>
! * @param vValue a value of any datatype
! * @return <code>true</code> if <code>vValue</code> is a string
! * and is either empty or composed of only whitespace
! * characters
! * @return <code>false</code> if <code>vValue</code> is either
! * not a string or is not an empty string and not a
! * string composed of only whitespace characters
* @return <code>null</code> if an exception is encountered
* @throws IllegalArgumentException
*/
! Validator.prototype.isBlankString = function(vValue) {
try {
***************
*** 60,69 ****
}
! if (typeof sValue != 'string') {
! throw vError = new TypeMismatchException('Validator.isBlankString', 'string', typeof sValue);
! }
!
! var bIsBlankString = (sValue.match(/[\w]/g)) ? false : true;
!
}
catch (vError) {
--- 66,70 ----
}
! var bIsBlankString = (typeof vValue != 'string') ? false : (vValue.match(/\S/g)) ? false : true;
}
catch (vError) {
***************
*** 81,97 ****
/**
! * Test if the supplied value is a single digit in the range 0 to 9
*
! * @summary is a single digit
* @author Stuart Wigley
! * @version 1.0, 09/19/03
! * @interface <code>Validator.isDigit(iValue)</code>
! * @param iValue the value to test against
! * @return true or false
* @return <code>null</code> if an exception is encountered
* @throws IllegalArgumentException
- * @throws TypeMismatchException
*/
! Validator.prototype.isDigit = function(iValue) {
try {
--- 82,101 ----
/**
! * Determine if the specified value is a single digit.
*
! * @summary is single digit?
* @author Stuart Wigley
! * @author Randolph Fielding
! * @version 1.1, 09/21/03
! * @interface <code>Validator.isDigit(vValue)</code>
! * @param vValue a value of any datatype
! * @return <code>true</code> if <code>vValue</code> is a number
! * and a single digit
! * @return <code>false</code> if <code>vValue</code> is either
! * not a number or is not a single digit
* @return <code>null</code> if an exception is encountered
* @throws IllegalArgumentException
*/
! Validator.prototype.isDigit = function(vValue) {
try {
***************
*** 104,113 ****
}
! if (typeof iValue != 'number') {
! throw vError = new TypeMismatchException('Validator.isDigit', 'number', typeof iValue);
! }
!
! var bIsDigit = ((iValue < 10) && iValue.toString().length == 1) ? true : false;
!
}
catch (vError) {
--- 108,112 ----
}
! var bIsDigit = (typeof vValue != 'number') ? false : ((vValue > 9) || (vValue.toString().length != 1)) ? false : true;
}
catch (vError) {
***************
*** 125,141 ****
/**
! * Test if the supplied value is an integer
*
! * @summary is an integer
* @author Stuart Wigley
! * @version 1.0, 09/19/03
! * @interface <code>Validator.isInteger(iValue)</code>
! * @param iValue the value to test against
! * @return true or false
* @return <code>null</code> if an exception is encountered
* @throws IllegalArgumentException
- * @throws TypeMismatchException
*/
! Validator.prototype.isInteger = function(iValue) {
try {
--- 124,143 ----
/**
! * Determine if the specified value is an integer.
*
! * @summary is integer?
* @author Stuart Wigley
! * @author Randolph Fielding
! * @version 1.1, 09/21/03
! * @interface <code>Validator.isInteger(vValue)</code>
! * @param vValue a value of any datatype
! * @return <code>true</code> if <code>vValue</code> is a number
! * and an integer
! * @return <code>false</code> if <code>vValue</code> is either
! * not a number or is not an integer
* @return <code>null</code> if an exception is encountered
* @throws IllegalArgumentException
*/
! Validator.prototype.isInteger = function(vValue) {
try {
***************
*** 148,157 ****
}
! if (typeof iValue != 'number') {
! throw vError = new TypeMismatchException('Validator.isInteger', 'number', typeof iValue);
! }
!
! var bIsInteger = (iValue.toString().indexOf('.') == -1) ? true : false;
!
}
catch (vError) {
--- 150,154 ----
}
! var bIsInteger = (typeof vValue != 'number') ? false : (vValue.toString().indexOf('.') != -1) ? false : true;
}
catch (vError) {
|