mirror of
https://github.com/IT4Change/gradido.git
synced 2026-01-20 20:01:31 +00:00
no autocomplete on username input, improved regex for username validations
This commit is contained in:
parent
2e3e9666e5
commit
41f15fc82c
@ -17,6 +17,7 @@
|
||||
:placeholder="placeholder"
|
||||
type="text"
|
||||
:state="validated ? valid : false"
|
||||
autocomplete="off"
|
||||
></b-form-input>
|
||||
<b-form-invalid-feedback v-bind="ariaMsg">
|
||||
<div v-if="showAllErrors">
|
||||
|
||||
@ -134,27 +134,24 @@ export const loadAllRules = (i18nCallback, apollo) => {
|
||||
|
||||
extend('usernameHyphens', {
|
||||
validate(value) {
|
||||
return !!value.match(/^[a-zA-Z0-9]+(?:[_-][a-zA-Z0-9])*$/)
|
||||
return !!value.match(/^[a-zA-Z0-9]+(?:[_-][a-zA-Z0-9]+?)*$/)
|
||||
},
|
||||
message: (_, values) => i18nCallback.t('form.validation.username-hyphens', values),
|
||||
})
|
||||
|
||||
extend('usernameUnique', {
|
||||
validate(value) {
|
||||
if (value.match(/^(?=.{3,20}$)[a-zA-Z0-9]+(?:[_-][a-zA-Z0-9])*$/)) {
|
||||
return apollo
|
||||
.query({
|
||||
query: checkUsername,
|
||||
variables: { username: value },
|
||||
})
|
||||
.then(({ data }) => {
|
||||
return {
|
||||
valid: data.checkUsername,
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
if (!value.match(/^(?=.{3,20}$)[a-zA-Z0-9]+(?:[_-][a-zA-Z0-9]+?)*$/)) return true
|
||||
return apollo
|
||||
.query({
|
||||
query: checkUsername,
|
||||
variables: { username: value },
|
||||
})
|
||||
.then(({ data }) => {
|
||||
return {
|
||||
valid: data.checkUsername,
|
||||
}
|
||||
})
|
||||
},
|
||||
message: (_, values) => i18nCallback.t('form.validation.username-unique', values),
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user