@compas/code-gen
Version:
Generate various boring parts of your server
743 lines (741 loc) • 26.2 kB
JavaScript
// Generated by @compas/code-gen
/* eslint-disable no-unused-vars */
import {
anonymousValidator127554530,
anonymousValidator1287070944,
anonymousValidator1312175728,
anonymousValidator1377926226,
anonymousValidator1390215584,
anonymousValidator1413365072,
anonymousValidator1421326295,
anonymousValidator1441913722,
anonymousValidator1474724230,
anonymousValidator1519740867,
anonymousValidator1664519436,
anonymousValidator1672152398,
anonymousValidator17105276,
anonymousValidator17476225,
anonymousValidator1787806021,
anonymousValidator1836970168,
anonymousValidator2019605291,
anonymousValidator2029084423,
anonymousValidator20588538,
anonymousValidator2067293249,
anonymousValidator224332322,
anonymousValidator243901689,
anonymousValidator508679687,
anonymousValidator512566754,
anonymousValidator682118687,
anonymousValidator682551261,
anonymousValidator980814292,
} from "../common/anonymous-validators.js";
import { AppError, isNil } from "@compas/stdlib";
/**
* @template T
* @typedef {import("@compas/stdlib").Either<T, AppError>} Either
*/
/**
* @param {undefined|any|import("../common/types").CodeGenAnyOfTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenAnyOfType>}
*/
export function validateCodeGenAnyOfType(value, propertyPath = "$") {
const result = anonymousValidator20588538(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenAnyOfType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenAnyTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenAnyType>}
*/
export function validateCodeGenAnyType(value, propertyPath = "$") {
const result = anonymousValidator1519740867(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenAnyType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenArrayTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenArrayType>}
*/
export function validateCodeGenArrayType(value, propertyPath = "$") {
const result = anonymousValidator1312175728(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenArrayType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenBooleanTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenBooleanType>}
*/
export function validateCodeGenBooleanType(value, propertyPath = "$") {
const result = anonymousValidator17476225(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenBooleanType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenCollectableErrorInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenCollectableError>}
*/
export function validateCodeGenCollectableError(value, propertyPath = "$") {
const result = anonymousValidator2029084423(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenCollectableError}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenContextInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenContext>}
*/
export function validateCodeGenContext(value, propertyPath = "$") {
const result = anonymousValidator980814292(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenContext}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenCrudTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenCrudType>}
*/
export function validateCodeGenCrudType(value, propertyPath = "$") {
const result = anonymousValidator1787806021(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenCrudType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenDateTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenDateType>}
*/
export function validateCodeGenDateType(value, propertyPath = "$") {
const result = anonymousValidator2019605291(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenDateType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenExtendTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenExtendType>}
*/
export function validateCodeGenExtendType(value, propertyPath = "$") {
const result = anonymousValidator1421326295(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenExtendType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenFileInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenFile>}
*/
export function validateCodeGenFile(value, propertyPath = "$") {
const result = anonymousValidator682118687(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenFile}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenFileTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenFileType>}
*/
export function validateCodeGenFileType(value, propertyPath = "$") {
const result = anonymousValidator508679687(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenFileType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenGenericTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenGenericType>}
*/
export function validateCodeGenGenericType(value, propertyPath = "$") {
const result = anonymousValidator1377926226(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenGenericType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenNamePartInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenNamePart>}
*/
export function validateCodeGenNamePart(value, propertyPath = "$") {
const result = anonymousValidator2067293249(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenNamePart}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenNumberTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenNumberType>}
*/
export function validateCodeGenNumberType(value, propertyPath = "$") {
const result = anonymousValidator1441913722(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenNumberType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenObjectTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenObjectType>}
*/
export function validateCodeGenObjectType(value, propertyPath = "$") {
const result = anonymousValidator17105276(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenObjectType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenOmitTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenOmitType>}
*/
export function validateCodeGenOmitType(value, propertyPath = "$") {
const result = anonymousValidator1474724230(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenOmitType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenPickTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenPickType>}
*/
export function validateCodeGenPickType(value, propertyPath = "$") {
const result = anonymousValidator512566754(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenPickType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenReferenceTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenReferenceType>}
*/
export function validateCodeGenReferenceType(value, propertyPath = "$") {
const result = anonymousValidator127554530(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenReferenceType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenRelationTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenRelationType>}
*/
export function validateCodeGenRelationType(value, propertyPath = "$") {
const result = anonymousValidator243901689(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenRelationType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenRouteInvalidationTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenRouteInvalidationType>}
*/
export function validateCodeGenRouteInvalidationType(
value,
propertyPath = "$",
) {
const result = anonymousValidator224332322(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenRouteInvalidationType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenRouteTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenRouteType>}
*/
export function validateCodeGenRouteType(value, propertyPath = "$") {
const result = anonymousValidator1390215584(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenRouteType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenStringTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenStringType>}
*/
export function validateCodeGenStringType(value, propertyPath = "$") {
const result = anonymousValidator1672152398(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenStringType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenStructureInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenStructure>}
*/
export function validateCodeGenStructure(value, propertyPath = "$") {
const result = anonymousValidator1413365072(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenStructure}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenTemplateStateInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenTemplateState>}
*/
export function validateCodeGenTemplateState(value, propertyPath = "$") {
const result = anonymousValidator1664519436(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenTemplateState}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenType>}
*/
export function validateCodeGenType(value, propertyPath = "$") {
const result = anonymousValidator682551261(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenType}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenTypeSettingsInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenTypeSettings>}
*/
export function validateCodeGenTypeSettings(value, propertyPath = "$") {
const result = anonymousValidator1287070944(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenTypeSettings}} */
return { value: result.value };
}
/**
* @param {undefined|any|import("../common/types").CodeGenUuidTypeInput} value
* @param {string|undefined} [propertyPath]
* @returns {Either<import("../common/types").CodeGenUuidType>}
*/
export function validateCodeGenUuidType(value, propertyPath = "$") {
const result = anonymousValidator1836970168(value, propertyPath);
if (result.errors) {
const info = {};
for (const err of result.errors) {
if (isNil(info[err.propertyPath])) {
info[err.propertyPath] = err;
} else if (Array.isArray(info[err.propertyPath])) {
info[err.propertyPath].push(err);
} else {
info[err.propertyPath] = [info[err.propertyPath], err];
}
}
/** @type {{ error: AppError }} */
return {
error: AppError.validationError("validator.error", info),
};
}
/** @type {{ value: import("../common/types").CodeGenUuidType}} */
return { value: result.value };
}