fix #5607: schema: say what a valid configuration ID looks like
The 'pve-configid' format is used for many IDs, for example the names of resource mappings, but an invalid ID only got rejected with: invalid configuration ID 'gpu@node1' which does not tell what is wrong with it, so users had to guess or look up the regex in the code. Explain the rules in the error message: an ID must start with a letter, be at least two characters long and only contain letters, digits, '-' and '_'. These are the same rules the tooltip of the 'ConfigId' validation in the web UI lists. Add a test for the message. Signed-off-by: Michal Fox <me@dualfroz.com>
This commit is contained in:
1 parent
927e892d87
commit
9373a6089b
2 files changed
+10
-1
No files matched your search
@@ -25,6 +25,14 @@ foreach my $id (@$invalid_configids) {
|
||||
is(PVE::JSONSchema::pve_verify_configid($id, $noerr), undef, 'invalid configid');
|
||||
}
|
||||
|
||||
eval { PVE::JSONSchema::pve_verify_configid('gpu@node1') };
|
||||
is(
|
||||
$@,
|
||||
"invalid configuration ID 'gpu\@node1' - it must start with a letter, be at least two"
|
||||
. " characters long and only contain letters, digits, '-' and '_'\n",
|
||||
'invalid configid error explains the format',
|
||||
);
|
||||
|
||||
# test some string rendering
|
||||
my $render_data = [
|
||||
["timestamp", 0, undef, "1970-01-01 01:00:00"],
|
||||
|
||||
Reference in new issue
Block a user