npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

joi-translation-es

v0.0.1

Published

Mensajes de error de validación de Joi para traducción al Español

Readme

Traducción al español de Joi

GitHub npm npm GitHub issues

:globe_with_meridians: Paquete que contiene mensajes de traducción al español neutro para los mensajes de error de validación del paquete Joi ("el lenguaje de descripción de esquemas y validador de datos más poderoso para JavaScript").

Motivación

Esta biblioteca fue creada debido a la necesidad de desarrollar aplicaciones reales para usuarios hispanohablantes. En este contexto, devolver mensajes de error de validación en inglés agrega una dificultad adicional a los proyectos. Por lo tanto, una biblioteca con mensajes traducidos se vuelve útil.

Instalación

Es importante destacar que este paquete no reemplaza a Joi. Es un complemento para Joi. Por lo tanto, asegúrate de tener instalado Joi en tu aplicación. Instala este paquete utilizando yarn:

yarn add joi-translation-pt-br

O con npm:

npm install joi-translation-pt-br

Ejemplos de Uso

Validación con esquema

El siguiente ejemplo se encuentra en examples/schema.

import Joi from 'joi';
import {messages} from 'joi-translation-es';

const schema = Joi.object().keys({
    nombre: Joi.string().required(),
    correo: Joi.string().email().required(),
});

const result = schema.validate({
    nombre: 'Leandro Santiago Gomes',
    correo: 'aaaa'
}, { messages });

if (result.error) {
    console.log(result.error.details);
}

Ejecutando el archivo con ts-node, se obtiene la respuesta en la terminal:

[
  {
    message: '"correo" debe ser un correo válido',
    path: [ 'correo' ],
    type: 'string.email',
    context: {...}
  }
]

Middleware Celebrate

import express from 'express';
import { celebrate, errors, Joi } from 'celebrate';
import { messages } from 'joi-translation-pt-br';

const middleware = celebrate({
    body: Joi.object().keys({
        correo: Joi.string().required().email(),
        contrasena: Joi.string().required(),
    }),
}, { abortEarly: false, messages });

const app = express();
app.use(express.json());

app.post('/test', middleware, (req, res) => {
    res.json();
});

app.use(errors());
app.listen(3333);

De esta manera, realizando solicitudes con un formato incorrecto, obtendremos la siguiente respuesta:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "Validation failed",
  "validation": {
    "body": {
      "source": "body",
      "keys": [
        "correo",
        "contrasena"
      ],
      "message": "\"correo\" debe ser un correo válido. \"contrasena\" es obligatoria"
    }
  }
}

Autor

Este paquete fue creado por Leandro Santiago Gomes basado en joi-translation-pt-br creado por Eduardo Oliveira

Licencia

Licencia MIT © Leandro Santiago Gomes