modify validation to support bluesky

Discovered while testing #1909

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

Refs: https://github.com/wesbos/awesome-uses/pull/1872
Refs: https://github.com/wesbos/awesome-uses/pull/1909

Co-authored-by: Kendall Morgan <1841529+kendallm@users.noreply.github.com>
This commit is contained in:
Christian Hain 2025-01-21 22:33:27 -05:00
parent 8a9eb35056
commit f77ab77db0
No known key found for this signature in database
GPG key ID: B81B655400BD708F
3 changed files with 11 additions and 2 deletions

View file

@ -62,6 +62,7 @@ module.exports.Schema = Joi.object({
.required(), .required(),
twitter: Joi.string().pattern(new RegExp(/^@?(\w){1,15}$/)), twitter: Joi.string().pattern(new RegExp(/^@?(\w){1,15}$/)),
mastodon: Joi.string().pattern(new RegExp(/^@(\w){1,30}@(\w)+\.(.?\w)+$/)), mastodon: Joi.string().pattern(new RegExp(/^@(\w){1,30}@(\w)+\.(.?\w)+$/)),
bluesky: Joi.string().pattern(new RegExp(/^[\w-]+\.(?:[\w-]+\.)?[\w-]+$/)),
emoji: Joi.string().allow(''), emoji: Joi.string().allow(''),
computer: Joi.string().valid('apple', 'windows', 'linux', 'bsd'), computer: Joi.string().valid('apple', 'windows', 'linux', 'bsd'),
phone: Joi.string().valid('iphone', 'android', 'windowsphone', 'flipphone'), phone: Joi.string().valid('iphone', 'android', 'windowsphone', 'flipphone'),

View file

@ -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.`
);
}
},
}), }),
}; };

View file

@ -1,7 +1,7 @@
/** /**
* @typedef Person * @typedef Person
* A single contributor with a /uses page. * 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} name - contributor's name
* @property {string} description - tagline for contributor * @property {string} description - tagline for contributor
* @property {string} url - link to contributor's /uses page * @property {string} url - link to contributor's /uses page
@ -18,7 +18,7 @@
/** /**
* List of all contributors with /uses pages. * List of all contributors with /uses pages.
* @type {Person[]} * @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. * Keep this a commonjs export.
*/ */