sickn33/agentic-awesome-skills · error · Error

Invalid email

Error message

Invalid email

What it means

Third guard in the fp-pragmatic validateUser example (skills/fp-pragmatic/SKILL.md:468). Thrown when email is a string but does not contain an @ character: a format check, distinct from the presence check at line 467.

Source

Thrown at skills/fp-pragmatic/SKILL.md:468

// Use it
pipe(
  getManagerEmail(employee),
  O.fold(
    () => sendToDefault(),
    (email) => sendTo(email)
  )
)
```

### Validation with Multiple Checks

```typescript
// Before: Throws on first error
function validateUser(data: unknown): User {
  if (!data || typeof data !== 'object') throw new Error('Must be object')
  const obj = data as Record<string, unknown>
  if (typeof obj.email !== 'string') throw new Error('Email required')
  if (!obj.email.includes('@')) throw new Error('Invalid email')
  if (typeof obj.age !== 'number') throw new Error('Age required')
  if (obj.age < 0) throw new Error('Age must be positive')
  return obj as User
}

// After: Returns first error, type-safe
const validateUser = (data: unknown): E.Either<string, User> =>
  pipe(
    E.Do,
    E.bind('obj', () =>
      typeof data === 'object' && data !== null
        ? E.right(data as Record<string, unknown>)
        : E.left('Must be object')
    ),
    E.bind('email', ({ obj }) =>
      typeof obj.email === 'string' && obj.email.includes('@')
        ? E.right(obj.email)
        : E.left('Valid email required')

View on GitHub (pinned to 58d857988f)

Solutions

  1. Replace the naive includes(@) with a real email format check: zod z.string().email(), a well-tested regex, or HTML5 input[type=email] plus server-side validation
  2. Collect this alongside other field errors using the doc Either-accumulating AFTER version
  3. Normalize (trim, lowercase) email before validating to avoid whitespace-driven false negatives

Example fix

// before
if (!obj.email.includes('@')) throw new Error('Invalid email')

// after
const EmailSchema = z.string().trim().toLowerCase().email()
const parsed = EmailSchema.safeParse(obj.email)
if (!parsed.success) errors.push('Invalid email')
Defensive patterns

Strategy: validation

Validate before calling

const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
const email = String(data.email ?? '').trim()
if (!EMAIL_RE.test(email)) {
  return badRequest('email format is invalid')
}

Type guard

const isValidEmail = (s: string): boolean =>
  /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s.trim())

Prevention

When it happens

Trigger: validateUser with email values like not-an-email, an empty string (no @), or userexample.com; note that the naive includes(@) check also lets malformed values like a@b pass.

Common situations: Free-text inputs with no client-side validation; typos; paste errors dropping the @; test fixtures with placeholder strings. Because the check is only includes(@), real code should use a proper regex or schema email format.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of sickn33/agentic-awesome-skills@58d857988f (2026-08-26). Data as JSON: /api/errors/587e97c29fa231ef. Report an issue: GitHub.