MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / validateBlockName

Function validateBlockName

tools/challenge-helper-scripts/utils.ts:287–301  ·  view source on GitHub ↗
(
  block: string,
  existingBlocks: string[]
)

Source from the content-addressed store, hash-verified

285};
286
287const validateBlockName = (
288 block: string,
289 existingBlocks: string[]
290): true | string => {
291 if (existingBlocks.includes(block.trim())) {
292 return 'a block with this name already exists';
293 }
294 if (!block.trim().length) {
295 return 'please enter a dashed name';
296 }
297 if (/[^a-z0-9-]/.test(block.trim())) {
298 return 'please use alphanumerical characters and kebab case';
299 }
300 return true;
301};
302
303export {
304 createStepFile,

Callers 5

rename-block.tsFile · 0.90
create-project.tsFile · 0.85
utils.test.tsFile · 0.85
create-quiz.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected