/**
 * @author Kalapuc Roman (rkalapuc@gmail.com)
 * @copyright Finport Technologies Inc
 * @since 2006
 * @version 1.0
 */

function wlpValidator(_params){
	this.params = new wlpPropertyList(_params);
}

wlpValidator.prototype.validate = function(value){
	return true;
}

/**
 * @author Kalapuc Roman (rkalapuc@gmail.com)
 * @copyright Finport Technologies Inc
 * @since 2006
 * @version 1.0
 */

function wlpNotEmptyValidator(_params){
	this.params = new wlpPropertyList(_params);	
}

wlpNotEmptyValidator.prototype = new wlpValidator;

wlpNotEmptyValidator.prototype.validate = function(value){
	var strValue = new String(value);
	
	if (strValue.length==0) return false;
		
	return true;
}

/**
 * @author Kalapuc Roman (rkalapuc@gmail.com)
 * @copyright Finport Technologies Inc
 * @since 2006
 * @version 1.0
 */

function wlpStringValidator(_params){
	this.params = new wlpPropertyList(_params);	
}

wlpStringValidator.prototype = new wlpValidator;

wlpStringValidator.prototype.validate = function(value){
	var strValue = new String(value);
	
	if (strValue.length!=0){
		var _p = this.params.get("maxlen");
		
		if (_p!==false){
			var _nMax = new Number(_p);
			if (strValue.length>_p) return false;
		}
			
		_p = this.params.get('minlen');
		if (_p!==false){
			var _nMin = new Number(_p);
			if (strValue.length<_p) return false;
		}
	}
	
	return true;
}

/**
 * @author Kalapuc Roman (rkalapuc@gmail.com)
 * @copyright Finport Technologies Inc
 * @since 2006
 * @version 1.0
 */

function wlpFileExtValidator(_params){
	this.params = new wlpPropertyList(_params);		
}

wlpFileExtValidator.prototype = new wlpValidator;

wlpFileExtValidator.prototype.validate = function(value){

	var strValue = new String(value);
	
	if (strValue.length!=0){
		
		var _p = this.params.get('ext');
	
		if (_p!==false){
			var strExt = new String(_p);			
			var strRegexp = "(.*)\.("+strExt+")$";

			var regexpInstance = new RegExp(strRegexp,"i");
			var match = regexpInstance.exec(strValue);
			
			if (match==null) return false;
		}	
	}
	
	return true;
}

