nocobase/nocobase · warning · Error

Must be 1-50 characters in length (excluding @.<>"'/)

Error message

Must be 1-50 characters in length (excluding @.<>"'/)

What it means

This error is thrown by a custom antd Form validator for the username field in the user-center edit-profile form. NocoBase enforces username constraints of 1-50 characters and disallows the characters @.<>"'/, verified by validateUsername(); when the value fails that check the validator throws with this i18n message, which antd displays under the field.

Source

Thrown at packages/plugins/@nocobase/plugin-users/src/client-v2/user-center/EditProfileItemModel.tsx:94

    >
      <Form form={form} layout="vertical">
        {errorMessage ? (
          <Alert type="error" showIcon message={errorMessage} style={{ marginBottom: token.marginMD }} />
        ) : null}
        <Form.Item name="nickname" label={t('Nickname')}>
          <Input autoComplete="name" />
        </Form.Item>
        <Form.Item
          name="username"
          label={t('Username')}
          rules={[
            { required: true, message: t('Username is required') },
            {
              validator: async (_, value) => {
                if (!value || validateUsername(value)) {
                  return;
                }
                throw new Error(t('Must be 1-50 characters in length (excluding @.<>"\'/)'));
              },
            },
          ]}
        >
          <Input autoComplete="username" />
        </Form.Item>
        <Form.Item
          name="email"
          label={t('Email')}
          rules={[{ type: 'email', message: t('Please enter a valid email address') }]}
        >
          <Input autoComplete="email" />
        </Form.Item>
        <Form.Item name="phone" label={t('Phone')}>
          <Input autoComplete="tel" />
        </Form.Item>
      </Form>
    </DrawerFormLayout>

View on GitHub (pinned to fa42722fef)

Solutions

  1. Remove the forbidden characters @.<>"'/ from the username
  2. Shorten the username to at most 50 characters
  3. Enter a non-empty username (1 char minimum)

Example fix

// before
username: "john.doe@corp"
// after
username: "john_doe"
Defensive patterns

Strategy: validation

Validate before calling

export function isValidUsername(v: unknown): boolean {
  return typeof v === 'string' && v.length >= 1 && v.length <= 50 && !/[@.<>"'\/]/.test(v);
}
if (!isValidUsername(username)) throw new Error('Invalid username');

Type guard

function isNonEmptyString(v: unknown): v is string { return typeof v === 'string' && v.length > 0; }

Try / catch

null

Prevention

When it happens

Trigger: User submits the Edit Profile drawer with a username containing any of the forbidden characters (@ . < > " ' /) or longer than 50 characters; the async validator runs on validate/submit and throws.

Common situations: Pasting an email address into the username field; usernames copied from URLs or identifiers containing slashes or dots; system-generated names exceeding 50 characters.

Related errors


AI-assisted analysis of nocobase/nocobase@fa42722fef (2026-09-01). Data as JSON: /api/errors/9faa49dd40d62fd2. Report an issue: GitHub.