Skip to content

Commit

Permalink
Improve Item name validation (#2451)
Browse files Browse the repository at this point in the history
Check that an Item name does not start with a number.

Closes #2444.

---------

Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 authored Mar 4, 2024
1 parent ccaa221 commit e288d0b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bundles/org.openhab.ui/web/src/components/item/item-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export default {
* @returns {string} The error message if the name is invalid, or an empty string if the name is valid.
*/
validateItemName (name) {
if (!/^[A-Za-z0-9_]+$/.test(name)) {
return 'Required. A-Z,a-z,0-9,_ only'
if (!/^[A-z][A-z0-9_]*$/.test(name)) {
return 'Required. Must not start with a number. A-Z,a-z,0-9,_ only'
} else if (this.items && this.items.some(item => item.name === name)) {
return 'An Item with this name already exists'
}
Expand Down

0 comments on commit e288d0b

Please sign in to comment.