0889ee9117
feat(hooks): add useLiveStream generic WebSocket hook - supports websocket/sse/polling transports - exponential backoff reconnect with jitter - circular buffer with configurable size - typed filter callback per use case - manual disconnect + reconnect + error state feat(hooks): add useLiveMetrics derived hook - sliding time-window cut - moving average (configurable window) - current / avg / min / max / ratePerSecond - zero allocations per tick (memoized) feat(charts): add LiveMetricChart molecule (Recharts) - line + area variants, grid + tooltip - moving-average overlay (dashed) - ConnectionStatus atom in header - status bar + compact mode - 100% responsive, GPU via SVG ViewBox feat(atoms): add ConnectionStatus indicator - 5 states: disconnected/connecting/connected/reconnecting/error - animated pulse, JetBrains Mono, pill style - exported helpers: formatLatency / formatBytes docs(pkg): bump v0.1.0 → v0.2.0, add recharts peerDep
39 lines
1.7 KiB
JavaScript
Executable File
39 lines
1.7 KiB
JavaScript
Executable File
// src/validators/index.ts
|
|
import { z } from "zod";
|
|
var emailSchema = z.string().trim().toLowerCase().email("Email inv\xE1lido").transform((v) => v);
|
|
var passwordSchema = z.string().min(8, "M\xEDnimo 8 caracteres").regex(/[A-Z]/, "Pelo menos 1 letra mai\xFAscula").regex(/[a-z]/, "Pelo menos 1 letra min\xFAscula").regex(/[0-9]/, "Pelo menos 1 n\xFAmero");
|
|
var passwordConfirmSchema = z.object({
|
|
password: passwordSchema,
|
|
confirm: z.string()
|
|
}).refine(({ password, confirm }) => password === confirm, {
|
|
message: "Senhas n\xE3o coincidem",
|
|
path: ["confirm"]
|
|
});
|
|
var uuidSchema = z.string().uuid("UUID inv\xE1lido");
|
|
var urlSchema = z.string().url("URL inv\xE1lida").or(z.literal("")).transform((v) => v === "" ? void 0 : v);
|
|
var phoneSchema = z.string().regex(/^(\+?55)?\s?\(?\d{2}\)?\s?\d{4,5}-?\d{4}$/, "Telefone inv\xE1lido \u2014 use (xx) xxxxx-xxxx");
|
|
var documentoSchema = z.string().transform((v) => v.replace(/\D/g, "")).refine((v) => v.length === 11 || v.length === 14, {
|
|
message: "CPF (11 d\xEDgitos) ou CNPJ (14 d\xEDgitos)"
|
|
});
|
|
function required(schema, msg = "Campo obrigat\xF3rio") {
|
|
return schema.refine((v) => !!v && String(v).trim().length > 0, { message: msg });
|
|
}
|
|
var sanitizedStr = z.string().transform((v) => v.replace(/<[^>]*>/g, "").trim()).pipe(z.string().min(1));
|
|
function safeParse(schema, data) {
|
|
const result = schema.safeParse(data);
|
|
return result.success ? { success: true, data: result.data } : { success: false, errors: result.error };
|
|
}
|
|
|
|
export {
|
|
emailSchema,
|
|
passwordSchema,
|
|
passwordConfirmSchema,
|
|
uuidSchema,
|
|
urlSchema,
|
|
phoneSchema,
|
|
documentoSchema,
|
|
required,
|
|
sanitizedStr,
|
|
safeParse
|
|
};
|
|
//# sourceMappingURL=chunk-BDJP3A46.mjs.map
|