UNPKG

@schemifyjs/core

Version:

Core module of the SchemifyJS CLI. Provides reusable functions such as scaffolding, template handling, and general utilities.

13 lines (12 loc) 512 B
export class NameValidator { static validate(name) { if (!name || typeof name !== 'string') { throw new Error(`Name is required and must be a string.`); } if (!this.NAME_REGEX.test(name)) { throw new Error(`Invalid name "${name}". Use only lowercase letters, numbers, and hyphens. Must start with a letter.`); } } } // Regla: minúsculas, números, guiones. No puede comenzar con número o guion NameValidator.NAME_REGEX = /^[a-z][a-z0-9\-]{1,}$/;