[英]Hapi/Joi validation of float()
I have the following JavaScript code to test out the Hapi/Joi validation functions: 我有以下JavaScript代码来测试Hapi / Joi验证函数:
var Joi = require('joi');
var schema = { free: Joi.Types.Number().float() };
var value = { free: 3.3333 };
var err = Joi.validate(value, schema);
//err is set if value fails to validate against the schema
if (err) throw err;
The validation throws the error: 验证会引发错误:
Error: the value of free must be an integer
I would like to know what I am doing wrong. 我想知道我做错了什么。 I am using the current versions of Hapi and Joi. 我正在使用当前版本的Hapi和Joi。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.