Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
import { describe, expect, it } from "vitest";
import { isValidEmail } from "../index.js";
describe("isValidEmail", () => {
it("accepts well-formed addresses", () => {
for (const ok of [
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
]) {
expect(isValidEmail(ok)).toBe(true);
}
});
it("rejects the design's malformed samples and other bad shapes", () => {
for (const bad of [
"2222@", // figma 347:1727 反例:@ 后无 domain
"Sam@", // 同上
"", // 空
" ", // 纯空白
"plainstring", // 无 @
"@example.com", // 无 local 段
"user@domain", // 无点分 TLD
"user@domain.", // TLD 空
"user@@example.com", // 双 @
"user @example.com", // 含空白
"user@ex ample.com", // domain 含空白
]) {
expect(isValidEmail(bad)).toBe(false);
}
});
it("trims surrounding whitespace before judging", () => {
expect(isValidEmail(" [email protected] ")).toBe(true);
expect(isValidEmail("\t[email protected]\n")).toBe(true);
});
});