Merge pull request #1180 from ultimatemember/fix/new_discord_usernames

Discord validation
This commit is contained in:
Nikita Sinelnikov
2023-05-04 22:23:27 +03:00
committed by GitHub
+2 -2
View File
@@ -306,10 +306,10 @@ if ( ! class_exists( 'um\core\Validation' ) ) {
if ( ! $string ) {
return true;
}
if ( substr_count( $string, '#' ) > 1 ) {
if ( strlen( $string ) < 2 || strlen( $string ) > 31 ) {
return false;
}
if ( ! preg_match( '/^(.+)#(\d+)$/', trim( $string ) ) ) {
if ( ! preg_match( '/^[a-z\d_]+(?:\.[a-z\d_]+)*(\.[a-z]*)?$/', trim( $string ) ) ) {
return false;
}
return true;