mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-21 23:36:15 -04:00
refactor: proper validation rules
Signed-off-by: Corentin Thomasset <corentin.thomasset74@gmail.com>
This commit is contained in:
parent
aa4fb5ffff
commit
17f3e7de35
2 changed files with 16 additions and 6 deletions
|
@ -4,7 +4,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## Next
|
## Next
|
||||||
- [fix] [UuidGenerator] added quantity validation rules (prevent < 0)
|
- [fix] [UuidGenerator] added quantity validation rules
|
||||||
|
|
||||||
## 1.2.0
|
## 1.2.0
|
||||||
- [feat] [UuidGenerator] can generate multiple uuids
|
- [feat] [UuidGenerator] can generate multiple uuids
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<v-text-field
|
<v-text-field
|
||||||
outlined
|
outlined
|
||||||
v-model="quantity"
|
v-model="quantity"
|
||||||
|
ref="quantity"
|
||||||
type="number"
|
type="number"
|
||||||
label="Quantity"
|
label="Quantity"
|
||||||
dense
|
dense
|
||||||
|
@ -24,7 +25,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {copyToClipboard} from "../../utils/helpers";
|
import {copyToClipboard, isInt} from "../../utils/helpers";
|
||||||
|
|
||||||
const noop = () => {
|
const noop = () => {
|
||||||
};
|
};
|
||||||
|
@ -39,10 +40,15 @@
|
||||||
rules: {
|
rules: {
|
||||||
quantity: [
|
quantity: [
|
||||||
v => !!v || 'Quantity is required',
|
v => !!v || 'Quantity is required',
|
||||||
v => v > 0 || 'Quantity should be > 0'
|
v => (v > 0 && v <= 50 ) || 'Quantity should be > 0 and <= 50',
|
||||||
|
v => isInt(v) || 'Quantity should be an integer'
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
isMounted:false
|
||||||
}),
|
}),
|
||||||
|
mounted() {
|
||||||
|
this.isMounted = true;
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
copyToken() {
|
copyToken() {
|
||||||
copyToClipboard(this.token);
|
copyToClipboard(this.token);
|
||||||
|
@ -51,9 +57,13 @@
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
token() {
|
token() {
|
||||||
if (this.refreshBool) noop(); // To force recomputation
|
if (this.isMounted && this.$refs.quantity.validate()) {
|
||||||
|
if (this.refreshBool) noop(); // To force recomputation
|
||||||
|
|
||||||
return Array.from({length: this.quantity}, generateUuid).join('\n');
|
return Array.from({length: this.quantity}, generateUuid).join('\n');
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue