salix/db/changes/10221-accountModule/00-user_checkName.sql

18 lines
524 B
SQL

DROP PROCEDURE IF EXISTS account.user_checkName;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `account`.`user_checkName`(vUserName VARCHAR(255))
BEGIN
/**
* Checks that username meets the necessary syntax requirements, otherwise it
* throws an exception.
* The user name must only contain lowercase letters or, starting with second
* character, numbers or underscores.
*/
IF vUserName NOT REGEXP '^[a-z0-9_-]*$' THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'INVALID_USER_NAME';
END IF;
END$$
DELIMITER ;