Skip to content

Viniciustda/OiTenta / .agents/skills/module-entity

module-entity

Verified

Cria entidades de domínio padronizadas para os módulos da aplicação, com estado tipado, herança da entidade base, validação explícita orientada por regras reutilizáveis do projeto e testes unitários completos para garantir segurança de evolução.

FileKindSize
SKILL.mdskill md10.9 KB
agents/openai.yamlconfig441 B
references/user-entity-pattern.mdmarkdown1.9 KB
references/validation-inference-guide.mdmarkdown2.1 KB

references/user-entity-pattern.md

View on GitHub
# User Entity Pattern

Esta referencia resume o padrao real observado em `modules/auth/src/user/model/user.entity.ts` e `modules/auth/test/user/model/user.entity.test.ts`.

## Estrutura da entidade

```ts
export interface UserState extends EntityState {
  name: string;
  email: string;
  password: string;
}

export class User extends Entity<UserState> {
  constructor(props: UserState) {
    super(props);
  }

  get name(): string {
    return this.props.name;
  }

  get email(): string {
    return this.props.email;
  }

  get password(): string {
    return this.props.password;
  }

  public validate(): void {
    Validator.validate([
      {
        code: "user.name",
        value: this.name,
        rules: [
          new RequiredRule(),
          new MinLengthRule(3),
          new MaxLengthRule(80),
          new PersonNameRule(),
        ],
      },
      {
        code: "user.email",
        value: this.email,
        rules: [new RequiredRule(), new EmailRule()],
      },
      {
        code: "user.password",
        value: this.password,
        rules: [new BcryptHashRule()],
      },
    ]);
  }
}
```

## Padroes a preservar

- `State` estende `EntityState`
- construtor apenas chama `super(props)`
- getters explicitos
- `validate()` manual e linear com `Validator.validate([...])`
- codigos de erro previsiveis via prefixo por campo

## Padrao dos testes

Cobrir pelo menos:

- criacao de entidade valida
- getters
- timestamps herdados da classe base
- `clone()` preservando `id` e `createdAt` e atualizando `updatedAt`
- lazy validation
- sucesso e falha de `validate()`
- mensagens de erro esperadas
- cenarios limite de tamanho e formato

Helper observado no projeto:

```ts
function getValidationMessages(callback: () => void): string[] {
  try {
    callback();
    return [];
  } catch (error) {
    return (error as ValidationException).errors.map((item) => item.message);
  }
}
```
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall