Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

344
Visualizações
What is the equivalent "Yup.transform" of Joi?

I'm using Yup package for data validation schemas but I would like to start to use Joi now. Or atleast, learn it.

This screenshot is what I have now for my app : My Yup version

And I would like to do exactly the same thing but with Joi and I can't find the equivalent of Yup's "transform()" method.

My need is simple: I have a property, I want to accept null values BUT if I get a null value, then I transform it to false (as you see in the screenshot above).

Thanks in advance !

UPDATE:


Yup.boolean().nullable().transform((value) => (value === null ? false : value));

UPDATE 2::

I tried this, it doesn't work :

Joi.boolean().allow(null).custom((value, helper) => {
                if (value === null) {
                    return false;
                }

                return value;
            });

The result of my unit test of the code above :

Expected: false
Received: null
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda