Skip to content

lowercase

awekrx edited this page May 29, 2026 · 1 revision

lowercase

Import

import { lowercase } from '@dev-suite/decorators/lowercase'

Category

  • parameter

Use Case

Normalize string parameter to lowercase.

Replaces

  • value.toLowerCase() in each method
  • Custom normalization helpers

Example 1

Without decorator

class UserService {
  findByEmail(email: string) {
    return this.repo.findByEmail(email.toLowerCase());
  }
}

With decorator

import { lowercase } from '@dev-suite/decorators/lowercase';

class UserService {
  findByEmail(@lowercase() email: string) {
    return this.repo.findByEmail(email);
  }
}

Why better

  • Centralizes cross-cutting behavior.
  • Method/class/property code stays focused on domain logic.

Example 2

Without decorator

class TagService {
  add(tag: string) {
    return this.store.add(tag.toLowerCase());
  }
}

With decorator

import { lowercase } from '@dev-suite/decorators/lowercase';

class TagService {
  add(@lowercase() tag: string) {
    return this.store.add(tag);
  }
}

Why better

  • Second scenario reuses same policy without duplication.
  • Behavior is more consistent and easier to audit.

Clone this wiki locally