Skip to content
Snippets Groups Projects

Issue #3335656: Refactor the OpenStack Heat name so that spaces cannot be entered

@@ -261,6 +261,24 @@ class OpenStackStackCreateExtraForm extends AwsCloudContentForm {
$this->tempStore->delete('environment');
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state): void {
parent::validateForm($form, $form_state);
$name = $form_state->getValue('name') ?? '';
// @see https://docs.openstack.org/api-ref/orchestration/v1/index.html#create-stack
if (!empty($name)
&& !preg_match('/^[a-zA-Z][a-zA-Z0-9_.-]{0,254}$/', $name)) {
$form_state->setError($form, $this->t("The @type %name is invalid:<ul><li>Must be unique within the project.</li><li>Must begin with an ASCII character.</li><li>It cannot contain anything other than ASCII characters, numbers, underscores, periods, and hyphens.</li></ul>", [
'@type' => $this->getShortEntityTypeNameWhitespace($this->entity),
'%name' => $name,
]));
}
}
/**
* Build template parameters.
*
Loading