ERequiredViolation = function() {
	this.message = function(fieldName) {
		return 'Не сте попълнили полето "' + fieldName + '".';
	}
}

EMinMaxConstraintsViolation = function(min, max, violationKind) {
	this.min = min;
	this.max = max;
	this.violationKind = violationKind;
	
	this.message = function(fieldName) {
	  var result = 'Невалидна стойност на полето "' + fieldName + '".\nСтойността трябва да е '; 
		 
    if (this.min && this.max) {
      result += 'между ' + this.min + ' и '+ this.max+'.';
    } else {
      if (!this.min) {
         result += 'по-малка от ' + this.max
      } else {
         result += 'по-голяма от ' + this.min
      }
    }
    
    return result
	}
}

EMaxLengthConstraintsViolation = function(maxLength) {
	this.maxLength = maxLength;	
	
	this.message = function(fieldName) {
		return 'Невалидна стойност на полето "' + fieldName + '".\nМаксималния брой символи е ' + this.maxLength+'.';
	}
}

         

EIntegerConstraintsViolation = EMinMaxConstraintsViolation;
EDateConstraintsViolation = EMinMaxConstraintsViolation
ERealTypeViolation = EMinMaxConstraintsViolation

EStringConstraintsViolation = EMaxLengthConstraintsViolation
EMemoConstraintsViolation = EMaxLengthConstraintsViolation



ESetConstraintsViolation = function(values, caseSensitive) {
	this.values = values;
	this.caseSensitive = caseSensitive;
	
	this.message = function(fieldName) {
		var res = 'Невалидна стойност на полето "' + fieldName + '".';
		res += '\nСтойността трябва да е измежду следните: ';
		for (var i = 0 ; i<this.values.length; i++) {
			res += '"' + his.values[i].toString() + '"';
			if (i < this.values.length-1) res += ', ';
		}
		res += '.';
		if (!this.caseSensitive) res += '\n(без значениe от главни или малки букви)';
		return res;
	}
}


EBooleanConstraintsViolation = function(mustValue) {
	this.mustValue = mustValue;
	
	this.message = function(fieldName) {
		return 'Невалидна стойност на полето "' + fieldName + '".\nСтойността на полето трябва да е ' + (this.mustValue?'"да"':'"не"')+'.';
		
	}
}

//-------------------

ETypeViolation = function(value, type) {
	this.value = value;
	this.type = type;
	
	this.message = function(fieldName) {
		return 'Невалидна стойност на полето "' + fieldName + '".\nСтойността трябва да е ' + this.type + '.';	
	}
}

EIntegerTypeViolation = function(value) {
	this.value = value;
	this.type = 'число';
	this.e = new ETypeViolation(this.value, this.type);
	this.message = this.e.message;
}
EDateTypeViolation = function(value) {
	this.value = value;
	this.type = 'дата';
	this.e = new ETypeViolation(this.value, this.type);
	this.message = this.e.message;
}
EFloatTypeViolation = EIntegerTypeViolation;

EStringTypeViolation = function(value) {
	this.value = value;
	this.type = 'текст';
	this.e = new ETypeViolation(this.value, this.type);
	this.message = this.e.message;
}
EMemoTypeViolation = function(value) {
	this.value = value;
	this.type = 'текст';
	this.e = new ETypeViolation(this.value, this.type);
	this.message = this.e.message;
}
ESetTypeViolation = function(value) {
	this.value = value;
	this.type = 'множество';
	this.e = new ETypeViolation(this.value, this.type);
	this.message = this.e.message;
}
EBooleanTypeViolation = function(value) {
	this.value = value;
	this.type = 'да/не';
	this.e = new ETypeViolation(this.value, this.type);
	this.message = this.e.message;
}


