nocobase/nocobase · error
Incorrect email format
Error message
Incorrect email format
What it means
The email transform validates each imported email value against a permissive regex before persisting it and throws when the value does not match. Empty/whitespace-only values are passed through untouched. This is thrown as a plain Error whose message is already translated via ctx.t, surfacing to the import UI as a row-level failure.
Source
Thrown at packages/plugins/@nocobase/plugin-action-import/src/server/utils/transform.ts:24
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { dayjs, str2moment } from '@nocobase/utils';
import * as math from 'mathjs';
import { namespace } from '../../';
export async function _({ value, field }) {
return value;
}
export async function email({ value, field, ctx }) {
if (!value?.trim()) {
return value;
}
const emailReg = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
if (!emailReg.test(value)) {
throw new Error(ctx.t('Incorrect email format', { ns: namespace }));
}
return value;
}
export async function password({ value, field, ctx }) {
if (value === undefined || value === null) {
throw new Error(ctx.t('password is empty', { ns: namespace }));
}
return `${value}`;
}
export async function o2o({ value, column, field, ctx }) {
const { dataIndex, enum: enumData } = column;
const repository = ctx.db.getRepository(field.options.target);
let enumItem = null;
if (enumData?.length > 0) {
enumItem = enumData.find((e) => e.label === value);
}View on GitHub (pinned to fa42722fef)
Solutions
- Correct the offending cell to a plain valid email like user@example.com
- Trim leading/trailing characters and remove display-name or bracket wrappers
- Check for invisible characters (zero-width spaces, RTL marks) when the value looks valid; retype the value
- If the source data is bulk-invalid, clean it in the spreadsheet with a validation formula before import
Example fix
// before email: "Alice <alice@example.com>" // after email: "alice@example.com"
Defensive patterns
Strategy: validation
Validate before calling
const emailReg = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
if (value?.trim() && !emailReg.test(value)) {
throw new Error(`Invalid email in row: ${value}`);
} Type guard
function isValidEmail(value: unknown): value is string {
return typeof value === 'string' && /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(value);
} Try / catch
try {
await importer.import(file);
} catch (err) {
if (String(err.message).includes('Incorrect email format')) {
// surface row location to user and skip/fix the row
}
throw err;
} Prevention
- Apply spreadsheet data-validation (email) on the column before distributing the template
- Clean copy-pasted contact data of display names and brackets
- Watch for invisible Unicode characters in look-valid emails
- Trim and normalize the column with spreadsheet functions before import
When it happens
Trigger: An imported cell contains text like 'alice', 'a@', 'alice at x.com', or has stray characters/unicode the regex rejects, while being non-empty. The regex requires local-part@domain.tld with each dot-separated label non-empty.
Common situations: Copy-pasted contact lists with display names ('Alice <a@x.com>'), trailing punctuation ('a@x.com.'), concatenated columns, or placeholder values ('N/A') in the email column.
Related errors
- columns is empty
- Columns configuration is empty
- Invalid field: {{field}}
- Field not found: {{field}}
- Import validation. Field not found
AI-assisted analysis of nocobase/nocobase@fa42722fef (2026-09-01).
Data as JSON: /api/errors/ca2b6d162fb08afb.
Report an issue: GitHub.