This commit is contained in:
2019-03-25 21:58:36 +00:00
parent 736495687e
commit d340608798
4 changed files with 44 additions and 5 deletions

View File

@@ -14,8 +14,6 @@ TODO CLIENT STUFF
TODO NEXT
Being screamed at so shutting down for today :(
GZ VALIDATE
- Add rule isNumeric

View File

@@ -18,6 +18,20 @@ function isEmpty(o) {
return !o;
}
////////////////////////////////////
// isInt value??
//
//FROM HERE: https://stackoverflow.com/a/14794066/8939
//fast test if is an integer:
function isInt(value) {
var x;
if (isNaN(value)) {
return false;
}
x = parseFloat(value);
return (x | 0) === x;
}
////////////////////////////////////
// Get control from ref
//
@@ -146,5 +160,31 @@ export default {
} else {
return false;
}
},
///////////////////////////////
// INTEGER
//
Integer(v, ref) {
var ctrl = getControl(v, ref);
if(typeof ctrl == 'undefined'){
return false;
}
var value = getControlValue(ctrl);
if (isEmpty(value)) {
return false;
}
if(isInt(value)){
return false;
}
// "ErrorFieldValueNotInteger": "Value must be an integer"
var err = locale.get("ErrorFieldValueNotInteger");
return err;
}
};

View File

@@ -67,7 +67,8 @@ export default {
"RecordHistory",
"ErrorFieldLengthExceeded",
"ErrorStartDateAfterEndDate",
"ErrorRequiredFieldEmpty"
"ErrorRequiredFieldEmpty",
"ErrorFieldValueNotInteger"
],
decimalValidate(required) {
return { required: required, decimal: [2, this.formats.decimalSeparator] };

View File

@@ -26,8 +26,8 @@
v-model="obj.count"
:counter="10"
:label="this.$gzlocale.get('WidgetCount')"
ref="count"
:rules="[this.$gzv.Required(this,'count')]"
ref="count"
:rules="[this.$gzv.Integer(this,'count'),this.$gzv.Required(this,'count')]"
required
></v-text-field>
</v-flex>