diff options
-rw-r--r-- | elm/User/Register.elm | 3 | ||||
-rw-r--r-- | lib/VNWeb/Validation.pm | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/elm/User/Register.elm b/elm/User/Register.elm index f3a28d70..abbf5d63 100644 --- a/elm/User/Register.elm +++ b/elm/User/Register.elm @@ -85,7 +85,8 @@ view model = [ formField "username::Username" [ inputText "username" model.username Username GUE.valUsername , br_ 1 - , text "Preferred username. Must be lowercase and can only consist of alphanumeric characters." + , text "Preferred username. Must be lowercase, between 2 and 15 characters long and consist entirely of alphanumeric characters or a dash." + , text " Names that look like database identifiers (i.e. a single letter followed by several numbers) are also disallowed." ] , formField "email::E-Mail" [ inputText "email" model.email EMail GUE.valEmail diff --git a/lib/VNWeb/Validation.pm b/lib/VNWeb/Validation.pm index 0ea635ad..5ddc1ac3 100644 --- a/lib/VNWeb/Validation.pm +++ b/lib/VNWeb/Validation.pm @@ -19,7 +19,7 @@ TUWF::set custom_validations => { id => { uint => 1, max => 1<<40 }, editsum => { required => 1, length => [ 2, 5000 ] }, page => { uint => 1, min => 1, max => 1000, required => 0, default => 1 }, - username => { regex => qr/^[a-z0-9-]*$/, func => sub { $_[0] !~ /^-*[a-z][0-9]+-*$/ }, minlength => 2, maxlength => 15 }, + username => { regex => qr/^(?!-*[a-z][0-9]+-*$)[a-z0-9-]*$/, minlength => 2, maxlength => 15 }, password => { length => [ 4, 500 ] }, }; |