You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
372 B
JavaScript
15 lines
372 B
JavaScript
6 years ago
|
"use strict";
|
||
|
|
||
|
const errors = require("../errors");
|
||
|
const getValueType = require("../util/get-value-type");
|
||
|
|
||
|
module.exports = function createNullValidatorFunction(_options = {}) {
|
||
|
return function validateNull(value) {
|
||
|
if (value !== null) {
|
||
|
return new errors.ValidationError(`Expected null, got ${getValueType(value)} instead`);
|
||
|
} else {
|
||
|
return true;
|
||
|
}
|
||
|
};
|
||
|
};
|