{"record":{"id":"9faa49dd40d62fd2","repo":"nocobase/nocobase","slug":"must-be-1-50-characters-in-length-excluding","errorCode":null,"errorMessage":"Must be 1-50 characters in length (excluding @.<>\"'/)","messagePattern":"Must be 1-50 characters in length \\(excluding @\\.<>\"'/\\)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/plugins/@nocobase/plugin-users/src/client-v2/user-center/EditProfileItemModel.tsx","lineNumber":94,"sourceCode":"    >\n      <Form form={form} layout=\"vertical\">\n        {errorMessage ? (\n          <Alert type=\"error\" showIcon message={errorMessage} style={{ marginBottom: token.marginMD }} />\n        ) : null}\n        <Form.Item name=\"nickname\" label={t('Nickname')}>\n          <Input autoComplete=\"name\" />\n        </Form.Item>\n        <Form.Item\n          name=\"username\"\n          label={t('Username')}\n          rules={[\n            { required: true, message: t('Username is required') },\n            {\n              validator: async (_, value) => {\n                if (!value || validateUsername(value)) {\n                  return;\n                }\n                throw new Error(t('Must be 1-50 characters in length (excluding @.<>\"\\'/)'));\n              },\n            },\n          ]}\n        >\n          <Input autoComplete=\"username\" />\n        </Form.Item>\n        <Form.Item\n          name=\"email\"\n          label={t('Email')}\n          rules={[{ type: 'email', message: t('Please enter a valid email address') }]}\n        >\n          <Input autoComplete=\"email\" />\n        </Form.Item>\n        <Form.Item name=\"phone\" label={t('Phone')}>\n          <Input autoComplete=\"tel\" />\n        </Form.Item>\n      </Form>\n    </DrawerFormLayout>","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/nocobase/nocobase/blob/fa42722fefe44265490dff2c27d79e2882bce4fa/packages/plugins/@nocobase/plugin-users/src/client-v2/user-center/EditProfileItemModel.tsx#L76-L112","documentation":"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.","triggerScenarios":"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.","commonSituations":"Pasting an email address into the username field; usernames copied from URLs or identifiers containing slashes or dots; system-generated names exceeding 50 characters.","solutions":["Remove the forbidden characters @.<>\"'/ from the username","Shorten the username to at most 50 characters","Enter a non-empty username (1 char minimum)"],"exampleFix":"// before\nusername: \"john.doe@corp\"\n// after\nusername: \"john_doe\"","handlingStrategy":"validation","validationCode":"export function isValidUsername(v: unknown): boolean {\n  return typeof v === 'string' && v.length >= 1 && v.length <= 50 && !/[@.<>\"'\\/]/.test(v);\n}\nif (!isValidUsername(username)) throw new Error('Invalid username');","typeGuard":"function isNonEmptyString(v: unknown): v is string { return typeof v === 'string' && v.length > 0; }","tryCatchPattern":"null","preventionTips":["Validate usernames client-side before submitting the profile form","Strip forbidden characters on input instead of rejecting at submit","Document the 1-50 char and forbidden-character rules in your signup UI"],"tags":["form-validation","username","antd"],"backgroundTag":"username-validation-failed","analyzedSha":"fa42722fefe44265490dff2c27d79e2882bce4fa","analyzedAt":"2026-09-01T00:54:31.202Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}