+
+ private getConstraintFormat(constraint: Constraint): any {
+ switch (constraint.type) {
+ case ConstraintTypes.equal:
+ return {
+ [ConstraintTypes.equal]: constraint.value
+ }
+ case ConstraintTypes.less_or_equal:
+ return {
+ [ConstraintTypes.less_or_equal]: constraint.value
+ }
+ case ConstraintTypes.less_than:
+ return {
+ [ConstraintTypes.less_than]: constraint.value
+ }
+ case ConstraintTypes.greater_or_equal:
+ return {
+ [ConstraintTypes.greater_or_equal]: constraint.value
+ }
+ case ConstraintTypes.greater_than:
+ return {
+ [ConstraintTypes.greater_than]: constraint.value
+ }
+ case ConstraintTypes.in_range:
+ return {
+ [ConstraintTypes.in_range]: constraint.value
+ }
+ case ConstraintTypes.length:
+ return {
+ [ConstraintTypes.length]: constraint.value
+ }
+ case ConstraintTypes.max_length:
+ return {
+ [ConstraintTypes.max_length]: constraint.value
+ }
+ case ConstraintTypes.min_length:
+ return {
+ [ConstraintTypes.min_length]: constraint.value
+ }
+ case ConstraintTypes.pattern:
+ return {
+ [ConstraintTypes.pattern]: constraint.value
+ }
+ case ConstraintTypes.valid_values:
+ return {
+ [ConstraintTypes.valid_values]: constraint.value
+ }
+ default:
+ return;
+ }
+ }
+
+ private mapValuesToConstraint(type: string, value: any):Constraint {
+ let constraintType: ConstraintTypes;
+ let constraintValue: any;
+ if (!type) {
+ constraintType = ConstraintTypes.null;
+ constraintValue = "";
+ } else if(type === "valid_values"){
+ constraintType = ConstraintTypes.valid_values;
+ constraintValue = value;
+ } else if(type === "equal") {
+ constraintType = ConstraintTypes.equal;
+ constraintValue = value;
+ } else if(type === "greater_than") {
+ constraintType = ConstraintTypes.greater_than;
+ constraintValue = value;
+ } else if(type === "greater_or_equal") {
+ constraintType = ConstraintTypes.greater_or_equal;
+ constraintValue = value;
+ } else if(type === "less_than") {
+ constraintType = ConstraintTypes.less_than;
+ constraintValue = value;
+ } else if(type === "less_or_equal") {
+ constraintType = ConstraintTypes.less_or_equal;
+ constraintValue = value;
+ } else if(type === "in_range") {
+ constraintType = ConstraintTypes.in_range;
+ constraintValue = value;
+ } else if(type === "range_max_value" || type === "range_min_value") {
+ constraintType = ConstraintTypes.in_range;
+ constraintValue = value;
+ } else if(type === "length") {
+ constraintType = ConstraintTypes.length;
+ constraintValue = value;
+ } else if(type === "min_length") {
+ constraintType = ConstraintTypes.min_length;
+ constraintValue = value;
+ } else if(type === "max_length") {
+ constraintType = ConstraintTypes.max_length;
+ constraintValue = value;
+ } else if(type === "pattern") {
+ constraintType = ConstraintTypes.pattern;
+ constraintValue = value;
+ }
+ return {
+ type:constraintType,
+ value:constraintValue
+ }
+ }