mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 11:44:05 +08:00
With this change we update the validation of the libraries and application projects names to fully allow characters that make a valid NPM package name. http://json.schemastore.org/package has been used as reference. We also remove validators that are no longer needed. Closes #11051
22 lines
780 B
TypeScript
22 lines
780 B
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import { tags } from '@angular-devkit/core';
|
|
import { SchematicsException } from '@angular-devkit/schematics';
|
|
|
|
// Must start with a letter, and must contain only alphanumeric characters or dashes.
|
|
// When adding a dash the segment after the dash must also start with a letter.
|
|
export const htmlSelectorRe = /^[a-zA-Z][.0-9a-zA-Z]*(:?-[a-zA-Z][.0-9a-zA-Z]*)*$/;
|
|
|
|
export function validateHtmlSelector(selector: string): void {
|
|
if (selector && !htmlSelectorRe.test(selector)) {
|
|
throw new SchematicsException(tags.oneLine`Selector (${selector})
|
|
is invalid.`);
|
|
}
|
|
}
|