better validation

This commit is contained in:
Wes Bos 2020-01-10 13:44:02 -05:00
parent 52e9c7f3f9
commit 3a9ce9d6be
5 changed files with 363 additions and 70 deletions

176
package-lock.json generated
View file

@ -4,6 +4,11 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@actions/core": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz",
"integrity": "sha512-ZKdyhlSlyz38S6YFfPnyNgCDZuAF2T0Qv5eHflNWytPS8Qjvz39bZFMry9Bb/dpSnqWcNeav5yM2CTYpJeY+Dw=="
},
"@babel/code-frame": {
"version": "7.5.5",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
@ -926,43 +931,62 @@
"resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.4.tgz",
"integrity": "sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw=="
},
"@emotion/stylis": {
"version": "0.8.5",
"resolved": "https://registry.npmjs.org/@emotion/stylis/-/stylis-0.8.5.tgz",
"integrity": "sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ=="
},
"@emotion/unitless": {
"version": "0.7.5",
"resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.7.5.tgz",
"integrity": "sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg=="
},
"@hapi/address": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/@hapi/address/-/address-2.1.4.tgz",
"integrity": "sha512-QD1PhQk+s31P1ixsX0H0Suoupp3VMXzIVMSwobR3F3MSUO2YCV0B7xqLcUw/Bh8yuvd3LhpyqLQWTNcRmp6IdQ=="
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@hapi/address/-/address-4.0.0.tgz",
"integrity": "sha512-GDDpkCdSUfkQCznmWUHh9dDN85BWf/V8TFKQ2JLuHdGB4Yy3YTEGBzZxoBNxfNBEvreSR/o+ZxBBSNNEVzY+lQ==",
"requires": {
"@hapi/hoek": "^9.0.0"
}
},
"@hapi/bourne": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@hapi/bourne/-/bourne-1.3.2.tgz",
"integrity": "sha512-1dVNHT76Uu5N3eJNTYcvxee+jzX4Z9lfciqRRHCU27ihbUcYi+iSc2iml5Ke1LXe1SyJCLA0+14Jh4tXJgOppA=="
},
"@hapi/formula": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@hapi/formula/-/formula-2.0.0.tgz",
"integrity": "sha512-V87P8fv7PI0LH7LiVi8Lkf3x+KCO7pQozXRssAHNXXL9L1K+uyu4XypLXwxqVDKgyQai6qj3/KteNlrqDx4W5A=="
},
"@hapi/hoek": {
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.5.0.tgz",
"integrity": "sha512-7XYT10CZfPsH7j9F1Jmg1+d0ezOux2oM2GfArAzLwWe4mE2Dr3hVjsAL6+TFY49RRJlCdJDMw3nJsLFroTc8Kw=="
"version": "9.0.2",
"resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.0.2.tgz",
"integrity": "sha512-LyibKv2QnD9BPI5g2L+g85yiIPv3ajYpENGFgy4u0xCLPhXWG1Zdx29neSB8sgX0/wz6k5TMjHzTwJ6+DaBYOA=="
},
"@hapi/joi": {
"version": "15.1.1",
"resolved": "https://registry.npmjs.org/@hapi/joi/-/joi-15.1.1.tgz",
"integrity": "sha512-entf8ZMOK8sc+8YfeOlM8pCfg3b5+WZIKBfUaaJT8UsjAAPjartzxIYm3TIbjvA4u+u++KbcXD38k682nVHDAQ==",
"version": "17.0.2",
"resolved": "https://registry.npmjs.org/@hapi/joi/-/joi-17.0.2.tgz",
"integrity": "sha512-84icw1yV3vbRzUidqFli1Gqr8diigOhTuKzlu3gqBXBm4Lukqe5apjyeJJhGO4rO/J3NiRjy1vXQ5bmhc5+fUA==",
"requires": {
"@hapi/address": "2.x.x",
"@hapi/bourne": "1.x.x",
"@hapi/hoek": "8.x.x",
"@hapi/topo": "3.x.x"
"@hapi/address": "^4.0.0",
"@hapi/formula": "^2.0.0",
"@hapi/hoek": "^9.0.0",
"@hapi/pinpoint": "^2.0.0",
"@hapi/topo": "^5.0.0"
}
},
"@hapi/pinpoint": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@hapi/pinpoint/-/pinpoint-2.0.0.tgz",
"integrity": "sha512-vzXR5MY7n4XeIvLpfl3HtE3coZYO4raKXW766R6DZw/6aLqR26iuZ109K7a0NtF2Db0jxqh7xz2AxkUwpUFybw=="
},
"@hapi/topo": {
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.6.tgz",
"integrity": "sha512-tAag0jEcjwH+P2quUfipd7liWCNX2F8NvYjQp2wtInsZxnMlypdw0FtAOLxtvvkO+GSRRbmNi8m/5y42PQJYCQ==",
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-5.0.0.tgz",
"integrity": "sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw==",
"requires": {
"@hapi/hoek": "^8.3.0"
"@hapi/hoek": "^9.0.0"
}
},
"@jimp/bmp": {
@ -4264,20 +4288,13 @@
}
},
"css-to-react-native": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-2.3.2.tgz",
"integrity": "sha512-VOFaeZA053BqvvvqIA8c9n0+9vFppVBAHCp6JgFTtTMU3Mzi+XnelJ9XC9ul3BqFzZyQ5N+H0SnwsWT2Ebchxw==",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-3.0.0.tgz",
"integrity": "sha512-Ro1yETZA813eoyUp2GDBhG2j+YggidUmzO1/v9eYBKR2EHVEniE2MI/NqpTQ954BMpTPZFsGNPm46qFB9dpaPQ==",
"requires": {
"camelize": "^1.0.0",
"css-color-keywords": "^1.0.0",
"postcss-value-parser": "^3.3.0"
},
"dependencies": {
"postcss-value-parser": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz",
"integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ=="
}
"postcss-value-parser": "^4.0.2"
}
},
"css-tree": {
@ -7457,6 +7474,35 @@
"yaml-loader": "^0.5.0"
},
"dependencies": {
"@hapi/address": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/@hapi/address/-/address-2.1.4.tgz",
"integrity": "sha512-QD1PhQk+s31P1ixsX0H0Suoupp3VMXzIVMSwobR3F3MSUO2YCV0B7xqLcUw/Bh8yuvd3LhpyqLQWTNcRmp6IdQ=="
},
"@hapi/hoek": {
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.5.0.tgz",
"integrity": "sha512-7XYT10CZfPsH7j9F1Jmg1+d0ezOux2oM2GfArAzLwWe4mE2Dr3hVjsAL6+TFY49RRJlCdJDMw3nJsLFroTc8Kw=="
},
"@hapi/joi": {
"version": "15.1.1",
"resolved": "https://registry.npmjs.org/@hapi/joi/-/joi-15.1.1.tgz",
"integrity": "sha512-entf8ZMOK8sc+8YfeOlM8pCfg3b5+WZIKBfUaaJT8UsjAAPjartzxIYm3TIbjvA4u+u++KbcXD38k682nVHDAQ==",
"requires": {
"@hapi/address": "2.x.x",
"@hapi/bourne": "1.x.x",
"@hapi/hoek": "8.x.x",
"@hapi/topo": "3.x.x"
}
},
"@hapi/topo": {
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.6.tgz",
"integrity": "sha512-tAag0jEcjwH+P2quUfipd7liWCNX2F8NvYjQp2wtInsZxnMlypdw0FtAOLxtvvkO+GSRRbmNi8m/5y42PQJYCQ==",
"requires": {
"@hapi/hoek": "^8.3.0"
}
},
"acorn": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz",
@ -9960,11 +10006,6 @@
"is-invalid-path": "^0.1.0"
}
},
"is-what": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/is-what/-/is-what-3.5.0.tgz",
"integrity": "sha512-00pwt/Jf7IaRh5m2Dp93Iw8LG2cd3OpDj3NrD1XPNUpAWVxPvBP296p4IiGmIU4Ur0f3f56IoIM+fS2pFYF+tQ=="
},
"is-windows": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz",
@ -10690,11 +10731,6 @@
"p-is-promise": "^2.0.0"
}
},
"memoize-one": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-5.1.1.tgz",
"integrity": "sha512-HKeeBpWvqiVJD57ZUAsJNm71eHTykffzcLZVYWiVfQeI1rJtuEaS7hQiEpWfVVk18donPwJEcFKIkCmPJNOhHA=="
},
"memory-fs": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz",
@ -10811,14 +10847,6 @@
}
}
},
"merge-anything": {
"version": "2.4.4",
"resolved": "https://registry.npmjs.org/merge-anything/-/merge-anything-2.4.4.tgz",
"integrity": "sha512-l5XlriUDJKQT12bH+rVhAHjwIuXWdAIecGwsYjv2LJo+dA1AeRTmeQS+3QBpO6lEthBMDi2IUMpLC1yyRvGlwQ==",
"requires": {
"is-what": "^3.3.1"
}
},
"merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
@ -15225,21 +15253,19 @@
}
},
"styled-components": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/styled-components/-/styled-components-4.4.1.tgz",
"integrity": "sha512-RNqj14kYzw++6Sr38n7197xG33ipEOktGElty4I70IKzQF1jzaD1U4xQ+Ny/i03UUhHlC5NWEO+d8olRCDji6g==",
"version": "5.0.0-rc.3",
"resolved": "https://registry.npmjs.org/styled-components/-/styled-components-5.0.0-rc.3.tgz",
"integrity": "sha512-FPezIfX26DigdMspk4rtL2Z4KMtgHcUK56Zb/XTXfs4XXBPFZefTNpi+pQEOkWRmE5r5dO9vzT7Hd+b78NtMLA==",
"requires": {
"@babel/helper-module-imports": "^7.0.0",
"@babel/traverse": "^7.0.0",
"@emotion/is-prop-valid": "^0.8.1",
"@emotion/unitless": "^0.7.0",
"@babel/traverse": "^7.4.5",
"@emotion/is-prop-valid": "^0.8.3",
"@emotion/stylis": "^0.8.4",
"@emotion/unitless": "^0.7.4",
"babel-plugin-styled-components": ">= 1",
"css-to-react-native": "^2.2.2",
"memoize-one": "^5.0.0",
"merge-anything": "^2.2.4",
"prop-types": "^15.5.4",
"react-is": "^16.6.0",
"stylis": "^3.5.0",
"css-to-react-native": "^3.0.0",
"hoist-non-react-statics": "^3.0.0",
"shallowequal": "^1.1.0",
"stylis-rule-sheet": "^0.0.10",
"supports-color": "^5.5.0"
}
@ -15276,11 +15302,6 @@
}
}
},
"stylis": {
"version": "3.5.4",
"resolved": "https://registry.npmjs.org/stylis/-/stylis-3.5.4.tgz",
"integrity": "sha512-8/3pSmthWM7lsPBKv7NXkzn2Uc9W7NotcwGNpJaa3k7WMM1XDCA4MgT5k/8BIexd5ydZdboXtU90XH9Ec4Bv/Q=="
},
"stylis-rule-sheet": {
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/stylis-rule-sheet/-/stylis-rule-sheet-0.0.10.tgz",
@ -16870,6 +16891,35 @@
"workbox-window": "^4.3.1"
},
"dependencies": {
"@hapi/address": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/@hapi/address/-/address-2.1.4.tgz",
"integrity": "sha512-QD1PhQk+s31P1ixsX0H0Suoupp3VMXzIVMSwobR3F3MSUO2YCV0B7xqLcUw/Bh8yuvd3LhpyqLQWTNcRmp6IdQ=="
},
"@hapi/hoek": {
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-8.5.0.tgz",
"integrity": "sha512-7XYT10CZfPsH7j9F1Jmg1+d0ezOux2oM2GfArAzLwWe4mE2Dr3hVjsAL6+TFY49RRJlCdJDMw3nJsLFroTc8Kw=="
},
"@hapi/joi": {
"version": "15.1.1",
"resolved": "https://registry.npmjs.org/@hapi/joi/-/joi-15.1.1.tgz",
"integrity": "sha512-entf8ZMOK8sc+8YfeOlM8pCfg3b5+WZIKBfUaaJT8UsjAAPjartzxIYm3TIbjvA4u+u++KbcXD38k682nVHDAQ==",
"requires": {
"@hapi/address": "2.x.x",
"@hapi/bourne": "1.x.x",
"@hapi/hoek": "8.x.x",
"@hapi/topo": "3.x.x"
}
},
"@hapi/topo": {
"version": "3.1.6",
"resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-3.1.6.tgz",
"integrity": "sha512-tAag0jEcjwH+P2quUfipd7liWCNX2F8NvYjQp2wtInsZxnMlypdw0FtAOLxtvvkO+GSRRbmNi8m/5y42PQJYCQ==",
"requires": {
"@hapi/hoek": "^8.3.0"
}
},
"fs-extra": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.3.tgz",

View file

@ -10,6 +10,8 @@
]
},
"dependencies": {
"@actions/core": "^1.2.0",
"@hapi/joi": "^17.0.2",
"country-emoji": "^1.5.0",
"esm": "^3.2.25",
"gatsby": "^2.18.12",

View file

@ -1,6 +1,7 @@
import Joi from '@hapi/joi';
import core from '@actions/core';
import data from '../src/data.js';
import flags from './flags.js';
const schema = Joi.object({
name: Joi.string().required(),
@ -8,11 +9,13 @@ const schema = Joi.object({
url: Joi.string()
.uri()
.required(),
country: Joi.string().required(),
twitter: Joi.string(),
emoji: Joi.string(),
country: Joi.string()
.valid(...flags)
.required(),
twitter: Joi.string().pattern(new RegExp(/^@?(\w){1,15}$/)),
emoji: Joi.string().allow(''),
computer: Joi.string().valid('apple', 'windows', 'linux'),
phone: Joi.string().valid('iphone', 'ios', 'android'),
phone: Joi.string().valid('iphone', 'android'),
tags: Joi.array().items(Joi.string()),
});

238
scripts/flags.js Normal file
View file

@ -0,0 +1,238 @@
const flags = [
'🇦🇫',
'🇦🇱',
'🇩🇿',
'🇦🇸',
'🇦🇩',
'🇦🇴',
'🇦🇮',
'🇦🇶',
'🇦🇬',
'🇦🇷',
'🇦🇲',
'🇦🇼',
'🇦🇺',
'🇦🇹',
'🇦🇿',
'🇧🇸',
'🇧🇭',
'🇧🇩',
'🇧🇧',
'🇧🇾',
'🇧🇪',
'🇧🇿',
'🇧🇯',
'🇧🇲',
'🇧🇹',
'🇧🇴',
'🇧🇶',
'🇧🇦',
'🇧🇼',
'🇧🇻',
'🇧🇷',
'🇧🇳',
'🇧🇬',
'🇧🇫',
'🇧🇮',
'🇰🇭',
'🇨🇲',
'🇨🇦',
'🇨🇻',
'🇰🇾',
'🇨🇫',
'🇹🇩',
'🇨🇱',
'🇨🇳',
'🇨🇽',
'🇨🇨',
'🇨🇴',
'🇰🇲',
'🇨🇩',
'🇨🇬',
'🇨🇰',
'🇨🇷',
'🇭🇷',
'🇨🇺',
'🇨🇼',
'🇨🇾',
'🇨🇿',
'🇩🇰',
'🇩🇯',
'🇩🇲',
'🇩🇴',
'🇪🇨',
'🇪🇬',
'🇸🇻',
'🇬🇶',
'🇪🇷',
'🇪🇪',
'🇪🇹',
'🇫🇴',
'🇫🇯',
'🇫🇮',
'🇫🇷',
'🇬🇫',
'🇵🇫',
'🇹🇫',
'🇬🇦',
'🇬🇲',
'🇬🇪',
'🇩🇪',
'🇬🇭',
'🇬🇮',
'🇬🇧',
'🇬🇷',
'🇬🇱',
'🇬🇩',
'🇬🇵',
'🇬🇺',
'🇬🇹',
'🇬🇬',
'🇬🇳',
'🇬🇼',
'🇬🇾',
'🇭🇹',
'🇭🇳',
'🇭🇰',
'🇭🇺',
'🇮🇸',
'🇮🇳',
'🇮🇩',
'🇮🇷',
'🇮🇶',
'🇮🇪',
'🇮🇱',
'🇮🇹',
'🇨🇮',
'🇯🇲',
'🇯🇵',
'🇯🇪',
'🇯🇴',
'🇰🇿',
'🇰🇪',
'🇰🇮',
'🇰🇼',
'🇰🇬',
'🇱🇦',
'🇱🇻',
'🇱🇧',
'🇱🇸',
'🇱🇷',
'🇱🇾',
'🇱🇮',
'🇱🇹',
'🇱🇺',
'🇲🇴',
'🇲🇰',
'🇲🇬',
'🇲🇼',
'🇲🇾',
'🇲🇻',
'🇲🇱',
'🇲🇹',
'🇲🇭',
'🇲🇶',
'🇲🇷',
'🇲🇺',
'🇾🇹',
'🇲🇽',
'🇫🇲',
'🇲🇩',
'🇲🇨',
'🇲🇳',
'🇲🇪',
'🇲🇸',
'🇲🇦',
'🇲🇿',
'🇲🇲',
'🇳🇦',
'🇳🇷',
'🇳🇵',
'🇳🇱',
'🇳🇨',
'🇳🇿',
'🇳🇮',
'🇳🇪',
'🇳🇬',
'🇳🇺',
'🇳🇫',
'🇰🇵',
'🇲🇵',
'🇳🇴',
'🇴🇲',
'🇵🇰',
'🇵🇼',
'🇵🇸',
'🇵🇦',
'🇵🇬',
'🇵🇾',
'🇵🇪',
'🇵🇭',
'🇵🇳',
'🇵🇱',
'🇵🇹',
'🇵🇷',
'🇶🇦',
'🇷🇪',
'🇷🇴',
'🇷🇺',
'🇷🇼',
'🇼🇸',
'🇸🇲',
'🇸🇹',
'🇸🇦',
'🇸🇳',
'🇷🇸',
'🇸🇨',
'🇸🇱',
'🇸🇬',
'🇸🇰',
'🇸🇮',
'🇸🇧',
'🇸🇴',
'🇿🇦',
'🇬🇸',
'🇰🇷',
'🇸🇸',
'🇪🇸',
'🇱🇰',
'🇸🇩',
'🇸🇷',
'🇸🇯',
'🇸🇿',
'🇸🇪',
'🇨🇭',
'🇸🇾',
'🇹🇼',
'🇹🇯',
'🇹🇿',
'🇹🇭',
'🇹🇱',
'🇹🇬',
'🇹🇰',
'🇹🇴',
'🇹🇹',
'🇹🇳',
'🇹🇷',
'🇹🇲',
'🇹🇨',
'🇹🇻',
'🇺🇬',
'🇺🇦',
'🇦🇪',
'🇺🇾',
'🇺🇸',
'🇺🇿',
'🇻🇺',
'🇻🇦',
'🇻🇪',
'🇻🇳',
'🇼🇫',
'🇪🇭',
'🇾🇪',
'🇿🇲',
'🇿🇼',
'🏴󠁧󠁢󠁥󠁮󠁧󠁿',
];
export default flags;

View file

@ -99,7 +99,7 @@ const pages = [
url: 'http://gantlaborde.com/uses/',
twitter: '@gantlaborde',
emoji: '🔥',
country: 'US',
country: '🇺🇸',
computer: 'windows',
phone: 'iphone',
tags: [
@ -1472,7 +1472,7 @@ const pages = [
url: 'https://gist.github.com/zilahir/4aaf5907999ea53711b2d554d22b0f3f',
twitter: '@zilahy',
emoji: '🐶',
country: '🇫🇮| 🇭🇺',
country: '🇫🇮',
computer: 'apple',
phone: 'iphone',
tags: [
@ -1862,7 +1862,7 @@ const pages = [
url: 'https://carloscharris.com/uses',
twitter: '@Darkklitos',
emoji: '🔥',
country: 'co',
country: '🇨🇴',
computer: 'apple',
phone: 'android',
tags: [