Skip to content

Commit

Permalink
modify validation to support bluesky
Browse files Browse the repository at this point in the history
Discovered while testing wesbos#1909

This commit also uses pieces from wesbos#1872 that are related to the Bluesky property

Refs: wesbos#1872
Refs: wesbos#1909

Co-authored-by: Kendall Morgan <[email protected]>
  • Loading branch information
XianHain and kendallm committed Jan 22, 2025
1 parent 8a9eb35 commit f77ab77
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports.Schema = Joi.object({
.required(),
twitter: Joi.string().pattern(new RegExp(/^@?(\w){1,15}$/)),
mastodon: Joi.string().pattern(new RegExp(/^@(\w){1,30}@(\w)+\.(.?\w)+$/)),
bluesky: Joi.string().pattern(new RegExp(/^[\w-]+\.(?:[\w-]+\.)?[\w-]+$/)),
emoji: Joi.string().allow(''),
computer: Joi.string().valid('apple', 'windows', 'linux', 'bsd'),
phone: Joi.string().valid('iphone', 'android', 'windowsphone', 'flipphone'),
Expand Down
8 changes: 8 additions & 0 deletions src/components/Person.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,13 @@ Person.propTypes = {
);
}
},
bluesky(props, propName, componentName) {
if (!/^(\w)+\.(\w)+\.(\w)+$/.test(props[propName])) {
return new Error(
`Invalid prop \`${propName}\` supplied to` +
` \`${componentName}\`. This isn't a legit Bluesky handle.`
);
}
},
}),
};
4 changes: 2 additions & 2 deletions src/data.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @typedef Person
* A single contributor with a /uses page.
* Data is validated against the following schema https://github.com/wesbos/awesome-uses/blob/master/scripts/utils.js#L53-L68
* Data is validated against the following schema https://github.com/wesbos/awesome-uses/blob/master/scripts/utils.js#L53-L70
* @property {string} name - contributor's name
* @property {string} description - tagline for contributor
* @property {string} url - link to contributor's /uses page
Expand All @@ -18,7 +18,7 @@
/**
* List of all contributors with /uses pages.
* @type {Person[]}
* Data is validated against the following schema https://github.com/wesbos/awesome-uses/blob/master/scripts/utils.js#L53-L68
* Data is validated against the following schema https://github.com/wesbos/awesome-uses/blob/master/scripts/utils.js#L53-L70
*
* Keep this a commonjs export.
*/
Expand Down

0 comments on commit f77ab77

Please sign in to comment.