fixed rules change, now should return TRUE if no broken rules before it was false, what a world!
This commit is contained in:
@@ -147,17 +147,17 @@ export default {
|
|||||||
//
|
//
|
||||||
required(vm, ref) {
|
required(vm, ref) {
|
||||||
if (vm.formState.loading) {
|
if (vm.formState.loading) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ctrl = getControl(vm, ref);
|
var ctrl = getControl(vm, ref);
|
||||||
if (typeof ctrl == "undefined") {
|
if (typeof ctrl == "undefined") {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var value = getControlValue(ctrl);
|
var value = getControlValue(ctrl);
|
||||||
if (!isEmpty(value)) {
|
if (!isEmpty(value)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
|
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
|
||||||
@@ -178,16 +178,16 @@ export default {
|
|||||||
//
|
//
|
||||||
maxLength(vm, ref, max) {
|
maxLength(vm, ref, max) {
|
||||||
if (vm.formState.loading) {
|
if (vm.formState.loading) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
var ctrl = getControl(vm, ref);
|
var ctrl = getControl(vm, ref);
|
||||||
if (typeof ctrl == "undefined") {
|
if (typeof ctrl == "undefined") {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var value = getControlValue(ctrl);
|
var value = getControlValue(ctrl);
|
||||||
if (isEmpty(value)) {
|
if (isEmpty(value)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.length > max) {
|
if (value.length > max) {
|
||||||
@@ -204,7 +204,7 @@ export default {
|
|||||||
});
|
});
|
||||||
return err;
|
return err;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
@@ -212,7 +212,7 @@ export default {
|
|||||||
//
|
//
|
||||||
max255(vm, ref) {
|
max255(vm, ref) {
|
||||||
if (vm.formState.loading) {
|
if (vm.formState.loading) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
return this.maxLength(vm, ref, 255);
|
return this.maxLength(vm, ref, 255);
|
||||||
},
|
},
|
||||||
@@ -222,26 +222,26 @@ export default {
|
|||||||
//
|
//
|
||||||
datePrecedence(vm, refStart, refEnd) {
|
datePrecedence(vm, refStart, refEnd) {
|
||||||
if (vm.formState.loading) {
|
if (vm.formState.loading) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
var ctrlStart = getControl(vm, refStart);
|
var ctrlStart = getControl(vm, refStart);
|
||||||
if (typeof ctrlStart == "undefined") {
|
if (typeof ctrlStart == "undefined") {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ctrlEnd = getControl(vm, refEnd);
|
var ctrlEnd = getControl(vm, refEnd);
|
||||||
if (typeof ctrlEnd == "undefined") {
|
if (typeof ctrlEnd == "undefined") {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var valueStart = getControlValue(ctrlStart);
|
var valueStart = getControlValue(ctrlStart);
|
||||||
if (isEmpty(valueStart)) {
|
if (isEmpty(valueStart)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var valueEnd = getControlValue(ctrlEnd);
|
var valueEnd = getControlValue(ctrlEnd);
|
||||||
if (isEmpty(valueEnd)) {
|
if (isEmpty(valueEnd)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
valueStart = window.$gz.DateTime.fromISO(valueStart);
|
valueStart = window.$gz.DateTime.fromISO(valueStart);
|
||||||
@@ -250,7 +250,7 @@ export default {
|
|||||||
// if either is not valid.
|
// if either is not valid.
|
||||||
//moment.github.io/luxon/docs/manual/validity.html
|
//moment.github.io/luxon/docs/manual/validity.html
|
||||||
https: if (!valueStart.isValid || !valueEnd.isValid) {
|
https: if (!valueStart.isValid || !valueEnd.isValid) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valueStart > valueEnd) {
|
if (valueStart > valueEnd) {
|
||||||
@@ -263,7 +263,7 @@ export default {
|
|||||||
});
|
});
|
||||||
return err;
|
return err;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
@@ -272,16 +272,16 @@ export default {
|
|||||||
//
|
//
|
||||||
confirmMatch(vm, refFirst, refSecond) {
|
confirmMatch(vm, refFirst, refSecond) {
|
||||||
if (vm.formState.loading) {
|
if (vm.formState.loading) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
var ctrlFirst = getControl(vm, refFirst);
|
var ctrlFirst = getControl(vm, refFirst);
|
||||||
if (typeof ctrlFirst == "undefined") {
|
if (typeof ctrlFirst == "undefined") {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ctrlSecond = getControl(vm, refSecond);
|
var ctrlSecond = getControl(vm, refSecond);
|
||||||
if (typeof ctrlSecond == "undefined") {
|
if (typeof ctrlSecond == "undefined") {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
var valueFirst = getControlValue(ctrlFirst);
|
var valueFirst = getControlValue(ctrlFirst);
|
||||||
var valueSecond = getControlValue(ctrlSecond);
|
var valueSecond = getControlValue(ctrlSecond);
|
||||||
@@ -295,7 +295,7 @@ export default {
|
|||||||
});
|
});
|
||||||
return err;
|
return err;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
@@ -303,11 +303,11 @@ export default {
|
|||||||
//
|
//
|
||||||
integerValid(vm, ref) {
|
integerValid(vm, ref) {
|
||||||
if (vm.formState.loading) {
|
if (vm.formState.loading) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
var ctrl = getControl(vm, ref);
|
var ctrl = getControl(vm, ref);
|
||||||
if (typeof ctrl == "undefined") {
|
if (typeof ctrl == "undefined") {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//DEBUG
|
//DEBUG
|
||||||
@@ -315,11 +315,11 @@ export default {
|
|||||||
|
|
||||||
var value = getControlValue(ctrl);
|
var value = getControlValue(ctrl);
|
||||||
if (isEmpty(value)) {
|
if (isEmpty(value)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInt(value)) {
|
if (isInt(value)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// "ErrorFieldValueNotInteger": "Value must be an integer"
|
// "ErrorFieldValueNotInteger": "Value must be an integer"
|
||||||
@@ -337,14 +337,14 @@ export default {
|
|||||||
//
|
//
|
||||||
decimalValid(vm, ref) {
|
decimalValid(vm, ref) {
|
||||||
if (vm.formState.loading) {
|
if (vm.formState.loading) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
//TODO: Handle commas and spaces in numbers
|
//TODO: Handle commas and spaces in numbers
|
||||||
//as per window.$gz.translation rules for numbers
|
//as per window.$gz.translation rules for numbers
|
||||||
|
|
||||||
var ctrl = getControl(vm, ref);
|
var ctrl = getControl(vm, ref);
|
||||||
if (typeof ctrl == "undefined") {
|
if (typeof ctrl == "undefined") {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//DEBUG
|
//DEBUG
|
||||||
@@ -352,11 +352,11 @@ export default {
|
|||||||
|
|
||||||
var value = getControlValue(ctrl);
|
var value = getControlValue(ctrl);
|
||||||
if (isEmpty(value)) {
|
if (isEmpty(value)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNumber(value)) {
|
if (isNumber(value)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// "ErrorFieldValueNotDecimal": "Value must be a number"
|
// "ErrorFieldValueNotDecimal": "Value must be a number"
|
||||||
@@ -374,13 +374,13 @@ export default {
|
|||||||
// (was using this in testing on widget form notes field but not sure where else it's applicable)
|
// (was using this in testing on widget form notes field but not sure where else it's applicable)
|
||||||
userRequiredFields(vm, ref, formCustomTemplateFieldName) {
|
userRequiredFields(vm, ref, formCustomTemplateFieldName) {
|
||||||
if (vm.formState.loading) {
|
if (vm.formState.loading) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var template =
|
var template =
|
||||||
window.$gz.store.state.formCustomTemplate[vm.formCustomTemplateKey];
|
window.$gz.store.state.formCustomTemplate[vm.formCustomTemplateKey];
|
||||||
if (template === undefined) {
|
if (template === undefined) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
//See if control formCustomTemplateFieldName is in server required fields collection
|
//See if control formCustomTemplateFieldName is in server required fields collection
|
||||||
//this is a collection of both custom field definitions and standard form fields that are required
|
//this is a collection of both custom field definitions and standard form fields that are required
|
||||||
@@ -393,17 +393,17 @@ export default {
|
|||||||
|
|
||||||
//templateItem.required
|
//templateItem.required
|
||||||
if (templateItem === undefined || templateItem.required !== true) {
|
if (templateItem === undefined || templateItem.required !== true) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ctrl = getControl(vm, ref);
|
var ctrl = getControl(vm, ref);
|
||||||
if (typeof ctrl == "undefined") {
|
if (typeof ctrl == "undefined") {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var value = getControlValue(ctrl);
|
var value = getControlValue(ctrl);
|
||||||
if (!isEmpty(value)) {
|
if (!isEmpty(value)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
|
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
|
||||||
@@ -432,16 +432,16 @@ export default {
|
|||||||
// type: "text"
|
// type: "text"
|
||||||
|
|
||||||
if (vm.formState.loading) {
|
if (vm.formState.loading) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (templateItem.required !== true) {
|
if (templateItem.required !== true) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var value = subvm.GetValueForField(templateItem.dataKey);
|
var value = subvm.GetValueForField(templateItem.dataKey);
|
||||||
if (!isEmpty(value)) {
|
if (!isEmpty(value)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//It's empty and it's required so return error
|
//It's empty and it's required so return error
|
||||||
|
|||||||
Reference in New Issue
Block a user