mirror of
https://github.com/web3privacy/explorer-data.git
synced 2024-10-15 12:06:26 +02:00
categories validation
This commit is contained in:
parent
dba9a7f514
commit
219c103fb8
3 changed files with 23 additions and 17 deletions
|
@ -12,7 +12,7 @@
|
|||
name: Layer 2
|
||||
- id: hardware
|
||||
name: Hardware
|
||||
- id: vpm
|
||||
- id: vpn
|
||||
name: VPN
|
||||
- id: did
|
||||
name: DID
|
||||
|
@ -38,8 +38,8 @@
|
|||
name: NFT
|
||||
- id: other
|
||||
name: Other
|
||||
- id: alliance
|
||||
name: Alliance
|
||||
- id: alliances
|
||||
name: Alliances
|
||||
- id: mixing-management
|
||||
name: Mixing management
|
||||
- id: data-management
|
||||
|
@ -48,5 +48,7 @@
|
|||
name: Donate
|
||||
- id: rd
|
||||
name: R&D
|
||||
- id: mixing-services
|
||||
- id: mixing-service
|
||||
name: Mixing services
|
||||
- id: node
|
||||
name: Node
|
||||
|
|
|
@ -27,19 +27,28 @@ const matrix = {
|
|||
const schemaDir = "./schema";
|
||||
const schemas = await loadSchemas();
|
||||
|
||||
schemas.project.properties.categories.items.enum = w3pd.data.categories.map(c => c.id)
|
||||
|
||||
for (const col of Object.keys(w3pd.data)) {
|
||||
const validator = ajv.compile(schemas[matrix[col]]);
|
||||
const ids = []
|
||||
|
||||
for (const item of w3pd.data[col]) {
|
||||
const testName = `${col}/${item.id} ` + (col === 'projects' ? `[${item.categories?.join(', ')}]` : '')
|
||||
|
||||
if(Object.keys(item).length === 1) {
|
||||
continue
|
||||
if (ids.includes(item.id)) {
|
||||
Deno.test(testName + ' (id-duplicates)', () => {
|
||||
throw { message: `Duplicate project id="${item.id}"` }
|
||||
});
|
||||
}
|
||||
|
||||
Deno.test(`${col}/${item.id} ` + (col === 'projects' ? `[${item.categories?.join(', ')}]` : ''), () => {
|
||||
if(Object.keys(item).length > 1) {
|
||||
Deno.test(testName + ' (schema)', () => {
|
||||
if (!validator(item)) {
|
||||
throw validator.errors;
|
||||
}
|
||||
});
|
||||
}
|
||||
ids.push(item.id)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,11 +27,6 @@ export class W3PData {
|
|||
}
|
||||
const pDir = `${catDir}/${pd.name}`;
|
||||
const indexFn = `${pDir}/index.yaml`;
|
||||
try {
|
||||
await Deno.stat(indexFn);
|
||||
} catch(e) {
|
||||
continue
|
||||
}
|
||||
|
||||
const index = yaml.load(
|
||||
await Deno.readTextFile(indexFn),
|
||||
|
|
Loading…
Reference in a new issue