function convertXvalToValidateOptions(xRulesConfig) {
	// this is adapted from xVal.jquery.validate.js so that it can generate
	// the rule/message set rather than binding rules directly to DOM elements
	var vRules = {};
	var vMessages = {};

	// returns true only if object is empty
	function isEmpty(obj) {
		for (var i in obj) {
			return false;
		}
		return true;
	}

	for (var i = 0; i < xRulesConfig.Fields.length; i++) {
		var xFieldName = xRulesConfig.Fields[i].FieldName;
		var xFieldRules = xRulesConfig.Fields[i].FieldRules;

		var vFieldRules = {};
		var vFieldMessages = {};

		for (var j = 0; j < xFieldRules.length; j++) {
			var xRule = xFieldRules[j];
			if (xRule != null) {
				var ruleName = xRule.RuleName;
				var ruleParams = xRule.RuleParameters;
				var errorText = (typeof (xRule.Message) == 'undefined' ? null : xRule.Message);

				switch (ruleName) {
					case "Required":
						vFieldRules.required = true;
						if (errorText)
							vFieldMessages.required = errorText;
						break;
					case "Range":
						// NOTE: If DataAnnotations could be sending different types for string and DateTime,
						// implement the checks here if needed
						if (typeof (ruleParams.Min) == 'undefined') {
							vFieldRules.max = ruleParams.Max;
							if (errorText)
								vFieldMessages.max = errorText;
						}
						else if (typeof (ruleParams.Max) == 'undefined') {
							vFieldRules.min = ruleParams.Min;
							if (errorText)
								vFieldMessages.min = errorText;
						}
						else {
							vFieldRules.range = [ruleParams.Min, ruleParams.Max];
							if (errorText)
								vFieldMessages.range = errorText;
						}
						break;
					case "StringLength":
						// NOTE: the StringLengthAttribute only takes a max length parameter
						vFieldRules.maxlength = ruleParams.MaxLength;
						if (errorText)
							vFieldMessages.maxlength = errorText;
						break;
					case "DataType":
						switch (ruleParams.Type) {
							case "EmailAddress":
								vFieldRules.email = true;
								if (errorText)
									vFieldMessages.email = errorText;
								break;
							case "Integer":
								vFieldRules.digits = true;
								if (errorText)
									vFieldMessages.digits = errorText;
								break;
							case "Decimal":
								vFieldRules.number = true;
								if (errorText)
									vFieldMessages.number = errorText;
								break;
							case "Date":
								vFieldRules.date = true;
								if (errorText)
									vFieldMessages.date = errorText;
								break;
						}
						break;
				}
			}
			if (!isEmpty(vFieldRules))
				vRules[xFieldName] = vFieldRules;
			if (!isEmpty(vFieldMessages))
				vMessages[xFieldName] = vFieldMessages;
		}
	}
	removeNumberRuleForCurrency(vRules);
	return { rules: vRules, messages: vMessages };
}
