Viniciustda/OiTenta / .agents/skills/config-package-shared
config-package-shared
VerifiedReconstrói o pacote compartilhado base da aplicação, concentrando contratos reutilizáveis, classes base, erros de domínio, casos de uso e validações consumidas pelo backend, frontend e módulos de negócio.
assets/shared-template/test/validation/rules/date-extra-rules.test.ts
View on GitHubimport {
DateRangeRule,
DateStringRule,
FutureDateRule,
MaxDateRule,
MinDateRule,
PastDateRule,
TimeStringRule,
} from "../../../src/index";
describe("Date and time rules", () => {
beforeEach(() => {
jest.useFakeTimers().setSystemTime(new Date("2026-03-31T12:00:00.000Z"));
});
afterEach(() => {
jest.useRealTimers();
});
test("DateStringRule deve aceitar datas ISO 8601 validas", () => {
const rule = new DateStringRule();
expect(
rule.validate([
"2026-03-31",
"2026-03-31T12:30",
"2026-03-31T12:30:45Z",
"2026-03-31T12:30:45+03:00",
]),
).toBeNull();
expect(rule.validate("31/03/2026")).toBe("date.string");
expect(rule.validate("2026-02-30")).toBe("date.string");
expect(rule.validate("2026-03-31T24:00")).toBe("date.string");
expect(rule.validate("2026-03-31T12:00+24:00")).toBe("date.string");
expect(rule.validate(new Date())).toBe("date.string");
});
test("MinDateRule deve validar a data minima", () => {
const rule = new MinDateRule("2026-01-01");
const invalidConfigRule = new MinDateRule("data-invalida");
expect(rule.validate("2026-03-31")).toBeNull();
expect(rule.validate(new Date("2025-12-31T23:59:59.000Z"))).toBe("min.date");
expect(rule.validate({})).toBe("min.date");
expect(invalidConfigRule.validate("2026-03-31")).toBe("min.date");
});
test("MaxDateRule deve validar a data maxima", () => {
const rule = new MaxDateRule("2026-12-31");
const invalidConfigRule = new MaxDateRule("data-invalida");
expect(rule.validate([new Date("2026-03-31T00:00:00.000Z")])).toBeNull();
expect(rule.validate("2027-01-01")).toBe("max.date");
expect(invalidConfigRule.validate("2026-03-31")).toBe("max.date");
});
test("DateRangeRule deve validar intervalo de datas", () => {
const rule = new DateRangeRule("2026-01-01", "2026-12-31");
const invalidMinRule = new DateRangeRule("data-invalida", "2026-12-31");
const invalidMaxRule = new DateRangeRule("2026-01-01", "data-invalida");
expect(rule.validate("2026-06-01")).toBeNull();
expect(rule.validate("2025-12-31")).toBe("date.range");
expect(rule.validate("2027-01-01")).toBe("date.range");
expect(invalidMinRule.validate("2026-06-01")).toBe("date.range");
expect(invalidMaxRule.validate("2026-06-01")).toBe("date.range");
});
test("FutureDateRule deve aceitar apenas datas futuras", () => {
const rule = new FutureDateRule();
expect(rule.validate("2026-03-31T12:00:01.000Z")).toBeNull();
expect(rule.validate("2026-03-31T12:00:00.000Z")).toBe("future.date");
});
test("PastDateRule deve aceitar apenas datas passadas", () => {
const rule = new PastDateRule();
expect(rule.validate("2026-03-31T11:59:59.000Z")).toBeNull();
expect(rule.validate("2026-04-01T00:00:00.000Z")).toBe("past.date");
});
test("TimeStringRule deve validar horarios HH:mm e HH:mm:ss", () => {
const rule = new TimeStringRule();
expect(rule.validate("23:59")).toBeNull();
expect(rule.validate("23:59:59")).toBeNull();
expect(rule.validate("24:00")).toBe("time.string");
expect(rule.validate(1200)).toBe("time.string");
});
});
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |