mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
1 parent
c02b358dcc
commit
282acba77e
4 files changed
+83
No files matched your search
@@ -158,6 +158,7 @@
|
||||
"fuse.js": "^7.1.0",
|
||||
"generate-schema": "^2.6.0",
|
||||
"get-timezone-offset": "^1.0.5",
|
||||
"gtin-validator": "^1.0.0",
|
||||
"hash-wasm": "^4.12.0",
|
||||
"haversine": "^1.1.1",
|
||||
"heic-convert": "^2.1.0",
|
||||
|
||||
Generated
+7
@@ -362,6 +362,9 @@ dependencies:
|
||||
get-timezone-offset:
|
||||
specifier: ^1.0.5
|
||||
version: 1.0.5
|
||||
gtin-validator:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
hash-wasm:
|
||||
specifier: ^4.12.0
|
||||
version: 4.12.0
|
||||
@@ -12515,6 +12518,10 @@ packages:
|
||||
resolution: {integrity: sha512-V4GsyVamhmKefvcAKaoy0h6si0xX7ogwBoBSs2CTJwt7luW0oZzC0LhdkyuKV8PJAXr7Yaj8pMjCKD4GJ+eEMg==}
|
||||
dev: false
|
||||
|
||||
/gtin-validator@1.0.0:
|
||||
resolution: {integrity: sha512-yVH4c/zixK+XPcETYTTi4LDpapBnHq/LQNiEmRgACa9ijJr84hXN8CE8J++xq77uD9YfmZZEIPwJqttCjSoCDw==}
|
||||
dev: false
|
||||
|
||||
/guid-typescript@1.0.9:
|
||||
resolution: {integrity: sha512-Y8T4vYhEfwJOTbouREvG+3XDsjr8E3kIr7uf+JZ0BYloFsttiHU0WfvANVsR7TxNUJa/WpCnw/Ino/p+DeBhBQ==}
|
||||
dev: false
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
calculateCheckDigitForGTIN,
|
||||
getFormatOfGTIN,
|
||||
getFormatOfMinifiedGTIN,
|
||||
isValidGTIN,
|
||||
removeGTINLeadingZerosToUpcOrGTIN13,
|
||||
} from 'gtin-validator';
|
||||
import { useQueryParam } from '@/composable/queryParams';
|
||||
|
||||
const input = useQueryParam({ tool: 'gtin-validator', name: 'gtin', defaultValue: '' });
|
||||
|
||||
const results = computed(() => {
|
||||
if (!input.value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const gtin = input.value.trim();
|
||||
const getValueOrError = (func: () => string) => {
|
||||
try {
|
||||
return func();
|
||||
}
|
||||
catch (e: any) {
|
||||
return e.toString();
|
||||
}
|
||||
};
|
||||
const isValid = isValidGTIN(gtin);
|
||||
return {
|
||||
minified: getValueOrError(() => removeGTINLeadingZerosToUpcOrGTIN13(gtin)),
|
||||
format: getValueOrError(() => getFormatOfGTIN(gtin)),
|
||||
minifiedFormat: getValueOrError(() => getFormatOfMinifiedGTIN(gtin)),
|
||||
checkDigit: getValueOrError(() => isValid ? calculateCheckDigitForGTIN(gtin.slice(0, -1)) : calculateCheckDigitForGTIN(gtin)),
|
||||
isValid,
|
||||
message: getValueOrError(() => isValidGTIN(gtin, 'error') ? 'ok' : 'nok'),
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div style="max-width: 600px; margin: auto;">
|
||||
<c-input-text
|
||||
v-model:value="input"
|
||||
placeholder="Enter GTIN (e.g., 4006381333931)"
|
||||
label="GTIN:" label-position="left"
|
||||
mb-2
|
||||
/>
|
||||
|
||||
<n-card v-if="results" title="Validation">
|
||||
<n-alert v-if="!results.isValid" type="error" mb-2>
|
||||
{{ results.message }}
|
||||
</n-alert>
|
||||
<n-alert v-else type="success" mb-2>
|
||||
GTIN is valid
|
||||
</n-alert>
|
||||
|
||||
<input-copyable :value="results.format" label="Format:" label-position="left" label-width="120px" mb-1 />
|
||||
<input-copyable :value="results.minified" label="Minified:" label-position="left" label-width="120px" mb-1 />
|
||||
<input-copyable :value="results.minifiedFormat" label="Minified Format:" label-position="left" label-width="120px" mb-1 />
|
||||
<input-copyable :value="results.checkDigit" label="Check Digit:" label-position="left" label-width="120px" mb-1 />
|
||||
</n-card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Barcode } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'GTIN Validator',
|
||||
path: '/gtin-validator',
|
||||
description: 'Validate and display information about GTIN (Global Trade Identifier Number formerly EAN Number), UPC and other product codes formats',
|
||||
keywords: ['gtin', 'validator', 'ean', 'trade', 'identifier'],
|
||||
component: () => import('./gtin-validator.vue'),
|
||||
icon: Barcode,
|
||||
createdAt: new Date('2025-10-03'),
|
||||
category: 'Barcodes',
|
||||
});
|
||||
Reference in new issue
Block a user