Browse Source

Merge pull request #18 from amber-smalltalk/validation

Add validation to the prompts
Manfred Kröhnert 11 years ago
parent
commit
89e68b8832
1 changed files with 8 additions and 3 deletions
  1. 8 3
      template.js

+ 8 - 3
template.js

@@ -24,6 +24,9 @@ exports.warnOn = '*';
 
 // The actual init template.
 exports.template = function(grunt, init, done) {
+  init.prompts.name.message= 'Name of the Amber application.';
+  init.prompts.name.validator= /^[A-Z][A-Za-z0-9]*$/;
+  init.prompts.name.warning= 'Must be a valid class name: only alphanumeric and starting with an uppercase letter!';
 
   init.process({type: 'amber'}, [
     // Prompt for these values.
@@ -32,12 +35,14 @@ exports.template = function(grunt, init, done) {
     init.prompt('description', 'Amber Application.'),
     {
       name: 'namespace',
-      message: 'The namespace used to store your Amber Packages.',
+      message: 'Namespace of the new Amber package.',
+      validator: /^[a-z][a-z0-9\-]*$/,
+      warning: 'Only lowercase letters, numbers, and - are allowed in namespaces!'
     },
     {
       name: 'amber_version',
-      default: '>= 0.12.4',
-      message: 'The version of Amber to use. Must be >= 0.12.4',
+      default: '>=0.12.4',
+      message: 'Version of Amber to use. Must be >=0.12.4'
     },
     init.prompt('version'),
     init.prompt('repository'),