/*!
* Copyright (c) 2009 Francesco Mele jsbeans@francescomele.com
*
* This Software is licenced under the LGPL Licence (GNU Lesser General
* Public License).
* In addition to the LGPL Licence the Software is subject to the
* following conditions:
*
* i every modification must be public and comunicated to the Author
* ii every "jsbean" added to this library must be self consistent
* except for the dependence from jsbeans-x.x.x.js
* iii copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* Validator extensions for Regular Expressions
* @for Validator
* @namespace jsbeans
* @static
* */
jsbeans.Validator.regExp = {
/**
* Default messages for Validator.regExp extension
* @property regExp.messages
* @type JSON
* @static
* */
messages: {
en: "does not match with the given Regular Expression",
it: "non corrisponde alla espressione regolare fornita"
},
/**
* Tests {@param} <code class="param">input</code>'s value against given {@param} <code class="param">re</code>.
* @method assertFile
* @param input {DOM} the input to validate
* @param re {String} a Regular Expression
* @return {boolean} returns the result of <code class="param">re</code>.test(<code class="param">input</code>.value)
* @static
* */
assertRegExp: function(obj, arg) {
var re = eval(arg + ";");
return obj.value == "" || re.test(obj.value);
}
};