Index: trunk/extensions/OpenStackManager/special/SpecialNovaProject.php |
— | — | @@ -54,6 +54,7 @@ |
55 | 55 | $projectInfo['projectname'] = array( |
56 | 56 | 'type' => 'text', |
57 | 57 | 'label-message' => 'openstackmanager-projectname', |
| 58 | + 'validation-callback' => array( $this, 'validateProjectName' ), |
58 | 59 | 'default' => '', |
59 | 60 | 'section' => 'project/info', |
60 | 61 | ); |
— | — | @@ -372,6 +373,20 @@ |
373 | 374 | |
374 | 375 | return true; |
375 | 376 | } |
| 377 | + |
| 378 | + /** |
| 379 | + * @param $projectname |
| 380 | + * @param $alldata |
| 381 | + * @return bool|string |
| 382 | + */ |
| 383 | + function validateProjectName( $projectname, $alldata ) { |
| 384 | + if ( ! preg_match( "/^[a-z][a-z0-9\-_]*$/", $project ) ) { |
| 385 | + return Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'openstackmanager-badprojectname' ) ); |
| 386 | + } else { |
| 387 | + return true; |
| 388 | + } |
| 389 | + } |
| 390 | + |
376 | 391 | } |
377 | 392 | |
378 | 393 | class SpecialNovaProjectForm extends HTMLForm { |
Index: trunk/extensions/OpenStackManager/OpenStackManager.i18n.php |
— | — | @@ -126,6 +126,7 @@ |
127 | 127 | 'openstackmanager-action' => 'Action', |
128 | 128 | 'openstackmanager-createprojectfailed' => 'Failed to create project.', |
129 | 129 | 'openstackmanager-createdproject' => 'Created project.', |
| 130 | + 'openstackmanager-badprojectname' => 'Bad project name provided. Project names start with a-z, and can only contain a-z, 0-9, -, and _ characters.', |
130 | 131 | 'openstackmanager-projectlist' => 'Project list', |
131 | 132 | 'openstackmanager-backprojectlist' => 'Back to project list', |
132 | 133 | 'openstackmanager-deleteproject' => 'Delete project', |