Skip to content
Snippets Groups Projects
Commit a9d121ef authored by Yas Naoi's avatar Yas Naoi Committed by Yas Naoi
Browse files

Issue #3335656 by yas, sekinet: Refactor the OpenStack Heat name so that spaces cannot be entered

parent 1de8b394
No related branches found
No related tags found
3 merge requests!1759Issue #3356778: Release 5.1.1,!1679Issue #3349074: Fix the OpenStack Project create and edit form in SPA that "Member" cannot be saved due to a validation error,!1607Issue #3343582: Add the function to preview OpenStack stack in the SPA
......@@ -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.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment