Skip to content

Hex length invalid (odd length) #1421

@codati

Description

@codati

Context

  • node version: v6.11.5
  • joi version:13.1.2
  • environment (node, browser): node
  • used with (hapi, standalone, ...):standalone

What are you trying to achieve or the steps to reproduce ?

const Joi = require('joi');


const test = "edf";

const schema = Joi
                .string()
                .hex()
                .required();


const result = Joi.validate(test, schema);

console.log(result);
if(result.error)
{
  console.log('error');
}
else{
  const buffer = Buffer.from( result.value , "hex");
}

Which result you had ?

Buffer throw error
TypeError: Invalid hex string

What did you expect ?

Joi generate error for length hex invalid

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions