Wrap username validator for WTForms.
970769
def validate_username(form, field):
        """"""
        try:
            validate_username(field.data)
        except ValueError as e:
            raise ValidationError(e)

        try:
            user_profile = UserProfile.get_by_username(field.data)
            if current_userprofile.is_anonymous or \
                    (current_userprofile.user_id != user_profile.user_id and
                     field.data != current_userprofile.username):
                # NOTE: Form validation error.
                raise ValidationError(_('Username already exists.'))
        except NoResultFound:
            return
366914
def assert_valid_name(name: str) -> str:
    """"""
    error = is_valid_name_error(name)
    if error:
        raise error
    return name
698835
def username_or(user, attr):
    
    if not settings.ACCOUNTS_NO_USERNAME:
        attr = "username"
    value = getattr(user, attr)
    if callable(value):
        value = value()
    return value
49049
function (user) {
  if (user.id)
    return {_id: user.id};
  else if (user.username)
    return {username: user.username};
  else if (user.email)
    return {"emails.address": user.email};
  throw new Error("shouldn't happen (validation missed something)");
}
891175
def validate_instance_username(self, username):
        '''  '''
        # 1-16 alphanumeric characters - first character must be a letter -
        # cannot be a reserved MySQL word
        if re.match('[\w-]+$', username) is not None:
            if len(username) <= 16 and len(username) >= 1:
                if username[0].isalpha():
                    if username not in MYSQL_RESERVED_WORDS:
                        return True
        return '*** Error: Usernames must be 1-16 alphanumeric chracters, \
            first a letter, cannot be reserved MySQL word.'
1033170
def valid(self, name):
    
    name = re.sub('[^0-9a-zA-Z_]', '', name)
    if re.match('[0-9]', name):
      name = '_' + name
    return name
1010064
def validate_args(self):
        """"""
        def validate_name():
            allowed_re = '^[a-z](([a-z0-9_-]+)?([a-z0-9])?)?'
            assert isinstance(self.params['name'], basestring), (
                'Name must be a string, not %s' % repr(self.params['name']))
            assert re.match(allowed_re, self.params['name']), (
                'Invalid rule name: %s. Must match %s.' % (
                    repr(self.params['name']), repr(allowed_re)))
        validate_name()

        def validate_deps():
            if 'deps' in self.params:
                assert type(self.params['deps']) in (type(None), list), (
                    'Deps must be a list, not %s' % repr(self.params['deps']))
        validate_deps()
239698
function validate({ username, password }, { i18n }) {
  const errors = {}

  if (!username) {
    errors.username = i18n.t`Username is required`
  } else if (validUsernames.indexOf(username)) {
    errors.username = i18n.t`Sorry ${username}, you can't get in.`
  }

  return errors
}
795714
def validate_username_for_new_person(username):
    

    # is the username valid?

    validate_username(username)

    # Check for existing people

    count = Person.objects.filter(username__exact=username).count()
    if count >= 1:
        raise UsernameTaken(six.u(
            'The username is already taken. Please choose another. '
            'If this was the name of your old account please email %s')
            % settings.ACCOUNTS_EMAIL)

    # Check for existing accounts

    count = Account.objects.filter(username__exact=username).count()
    if count >= 1:
        raise UsernameTaken(six.u(
            'The username is already taken. Please choose another. '
            'If this was the name of your old account please email %s')
            % settings.ACCOUNTS_EMAIL)

    # Check account datastore, in case username created outside Karaage.

    if account_exists(username):
        raise UsernameTaken(
            six.u('Username is already in external account datastore.'))

    return username
881826
def getUserName(self):
        """"""
        if not self._server_side:
            return
        mech = self._authenticator.current_mech
        return mech.getUserName() if mech else None
1187617
def a_send_username(username, ctx):
    """"""
    if username:
        ctx.ctrl.sendline(username)
        return True
    else:
        ctx.ctrl.disconnect()
        raise ConnectionAuthenticationError("Username not provided", ctx.ctrl.hostname)
688304
def user_name_attributes(user, service):
    """"""
    attributes = {}
    attributes['username'] = user.get_username()
    attributes['full_name'] = user.get_full_name()
    attributes['short_name'] = user.get_short_name()
    return attributes
1267470
def clean(self):
        
        if self.user:
            self.username = self.user.username
        elif not self.username:
            raise ValidationError({
                'username': _NOT_BLANK_MESSAGE,
                'user': _NOT_BLANK_MESSAGE
            })
782559
private function checkAdminUser($wtname, $wtuser, $wtpass, $wtemail): string
    {
        if ($wtname === '' || $wtuser === '' || $wtpass === '' || $wtemail === '') {
            return I18N::translate('You must enter all the administrator account fields.');
        }

        if (mb_strlen($wtpass) < 6) {
            return I18N::translate('The password needs to be at least six characters long.');
        }

        return '';
    }
1151699
def chain_user_names(users, exclude_user, truncate=35):
    """"""
    if not users or not isinstance(exclude_user, get_user_model()):
        return ''
    return truncatechars(
        ', '.join(u'{}'.format(u) for u in users.exclude(pk=exclude_user.pk)),
        truncate)
762500
def username(self, value=None):
        
        if value is not None:
            return URL._mutate(self, username=value)
        return unicode_unquote(self._tuple.username)
1240760
def field_uuid(self, attr, options):
        """"""
        options['validators'].append(validators.UUIDValidator(attr.entity))
        return wtf_fields.StringField, options