trustwallet-assets/script/generic/tag-values.ts
Adam R 63c1dcaf1a
[Internal] Add check for tags field (array) (#5960)
* Add check for tags field (array)

* Lint fix

* Using reduce() instead of forEach() for checking all values

Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com>
2021-03-18 00:27:21 +01:00

20 lines
549 B
TypeScript

import { readJsonFile } from "../generic/json";
const tags: any = readJsonFile("script/tags.json") as any;
export function isValidTagValue(value: string): boolean {
//console.log(`isValidTagValue ${value}`);
if (!value) {
return false;
}
if (!(value in tags)) {
return false;
}
//console.log(`TAG ${tags[value]['name']}`);
return true;
}
export function isValidTagValues(values: string[]): boolean {
return values.reduce((accum: boolean, value: string) => accum && isValidTagValue(value), true);
}