dilswer
Version:
Blazingly fast data validation library with TypeScript integration.
35 lines (33 loc) • 1.12 kB
JavaScript
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
// src/data-types/types/null.ts
import { BaseType } from "../base-type.mjs";
import { getStandardSchemaProps } from "../generate-standard-schema.mjs";
import { ValidationError } from "../../validation-algorithms/validation-error/validation-error.mjs";
var NullType = class extends BaseType {
constructor() {
super();
__publicField(this, "kind", "simple");
__publicField(this, "simpleType", "null");
Object.freeze(this);
}
/** @internal */
_acceptVisitor(visitor) {
return visitor.visit(this);
}
get ["~standard"]() {
return getStandardSchemaProps(this);
}
["~validate"](path, value) {
if (value !== null) {
throw new ValidationError(path, this, value, "not a null");
}
}
["~matches"](value) {
return value === null;
}
};
export {
NullType
};