Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/validate-tooling-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,49 @@ jobs:
const data = yaml.load(fs.readFileSync(dataPath, 'utf-8'));
const ajv = new Ajv({ allErrors: true });
addFormats(ajv);

ajv.addKeyword({
keyword: 'caseInsensitiveUnique',
type: 'array',
validate: function (schema, data) {
if (!Array.isArray(data)) return false;

const languagesSet = new Set();
const languagesLowercaseSet = new Set();
data.forEach((tool) => {
if (tool.languages) {
tool.languages.forEach((language) => {
languagesSet.add(language);
languagesLowercaseSet.add(language.toLowerCase());
});
}
});
if (languagesSet.size !== languagesLowercaseSet.size) {
console.error('Duplicate languages found');
const lowercaseMap = new Map();
languagesSet.forEach((language) => {
lowercaseMap.set(
language.toLowerCase(),
(lowercaseMap.get(language.toLowerCase()) || 0) + 1
);
});

lowercaseMap.forEach((value, key) => {
if (value > 1) {
console.log('Duplicate found for:', key);
}
});
validate.errors = [{
keyword: 'caseInsensitiveUnique',
message: 'array contains case-insensitive duplicates',
params: { keyword: 'caseInsensitiveUnique' }
}];
return false;
}
return true;
}
});

const validate = ajv.compile(schema);
const valid = validate(data);
if (!valid) {
Expand Down
1 change: 1 addition & 0 deletions data/tooling-data.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"languages": {
"description": "The language or languages a tool is built in. In the case of a validator, this will likely be the language it is written in. In the case of a conversion or transformation tool, these are the languages that are supported in some capacity.",
"type": "array",
"caseInsensitiveUnique": true,
"items": {
"description": "Individual language name, from the list unless not included.",
"type": "string",
Expand Down
Loading