From 281c0461bf608e8ff2218c20702064c54c0e6c26 Mon Sep 17 00:00:00 2001 From: Matthew Baker Date: Mon, 8 Jun 2015 11:13:57 -0400 Subject: [PATCH] Update directive name validation Fleshed out validations to enforce angular naming rules https://github.com/angular/angular.js/commit/634e467172efa696eb32ef8942f fbedeecbd030e --- package.json | 2 +- utils.js | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index c73138f..00ded93 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "generator-cg-angular", - "version": "3.2.0", + "version": "3.2.1", "description": "Yeoman Generator for Enterprise Angular projects.", "keywords": [ "yeoman-generator", diff --git a/utils.js b/utils.js index 6ad5074..ed7559b 100755 --- a/utils.js +++ b/utils.js @@ -260,8 +260,17 @@ exports.addNamePrompt = function(that,prompts,type){ prompts.splice(0,0,{ name:'name', message: 'Enter a name for the ' + type + '.', - validate: function(input){ - return true; + validate: function(input) { + var valid = false; + switch (type) { + case 'directive': //https://github.com/angular/angular.js/commit/634e467172efa696eb32ef8942ffbedeecbd030e + valid = (input === input.trim()) && (input[0].toLowerCase() === input[0]); + break; + default: + valid = true; + } + + return valid; } }); }