-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
196 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npm run validate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "boycott-israeli-tech-companies-dataset", | ||
"version": "1.0.0", | ||
"description": "This repository is dedicated to providing a comprehensive list of Israeli tech companies to boycott, categorized based on their respective industries.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"validate": "node validators/companies/companies-validator.js", | ||
"prepare": "husky install" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"ajv": "^8.12.0", | ||
"husky": "^8.0.0", | ||
"yaml": "^2.3.4" | ||
}, | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Validate companies using JSON Schema | ||
|
||
const fs = require("fs"); | ||
const path = require("path"); | ||
const yaml = require("yaml"); | ||
const Ajv = require("ajv"); | ||
|
||
const companiesDatasetDir = path.join(__dirname, "../../", "dataset/companies"); | ||
const companySchema = path.join( | ||
__dirname, | ||
"../../", | ||
"validators/companies/company-schema.yaml" | ||
); | ||
|
||
// Load and parse YAML schema file | ||
const schemaFile = fs.readFileSync(companySchema, "utf8"); | ||
const schema = yaml.parse(schemaFile); | ||
|
||
// Create an Ajv instance | ||
const ajv = new Ajv(); | ||
const validate = ajv.compile(schema); | ||
|
||
// Get all categories (company files) | ||
const categories = fs.readdirSync(companiesDatasetDir); | ||
|
||
// Validate files 1 by 1 | ||
for (category of categories) { | ||
const companies = fs.readFileSync( | ||
`${companiesDatasetDir}/${category}`, | ||
"utf8" | ||
); | ||
const data = yaml.parse(companies); | ||
|
||
const valid = validate(data); | ||
if (!valid) { | ||
console.log("Validation errors:", validate.errors); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
console.log("YAML data is valid!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
Name: | ||
type: string | ||
maxLength: 50 | ||
Description: | ||
type: string | ||
maxLength: 500 | ||
Website: | ||
type: string | ||
maxLength: 50 | ||
Alternatives: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
Name: | ||
type: string | ||
maxLength: 50 | ||
Description: | ||
type: string | ||
maxLength: 500 | ||
Website: | ||
type: string | ||
maxLength: 50 | ||
required: | ||
- Name | ||
- Website | ||
additionalProperties: false | ||
required: | ||
- Name | ||
- Website | ||
additionalProperties: false |