id int64 0 3.78k | code stringlengths 13 37.9k | declarations stringlengths 16 64.6k |
|---|---|---|
2,400 | function resolve(
this: Ajv,
root: SchemaEnv, // information about the root schema for the current schema
ref: string // reference to resolve
): SchemaEnv | undefined {
let sch
while (typeof (sch = this.refs[ref]) == "string") ref = sch
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref)
... | class Ajv extends AjvCore {
_addVocabularies(): void {
super._addVocabularies()
draft7Vocabularies.forEach((v) => this.addVocabulary(v))
if (this.opts.discriminator) this.addKeyword(discriminator)
}
_addDefaultMetaSchema(): void {
super._addDefaultMetaSchema()
if (!this.opts.meta) return
... |
2,401 | function resolveSchema(
this: Ajv,
root: SchemaEnv, // root object with properties schema, refs TODO below SchemaEnv is assigned to it
ref: string // reference to resolve
): SchemaEnv | undefined {
const p = this.opts.uriResolver.parse(ref)
const refPath = _getFullPath(this.opts.uriResolver, p)
let baseId =... | class SchemaEnv implements SchemaEnvArgs {
readonly schema: AnySchema
readonly schemaId?: "$id" | "id"
readonly root: SchemaEnv
baseId: string // TODO possibly, it should be readonly
schemaPath?: string
localRefs?: LocalRefs
readonly meta?: boolean
readonly $async?: boolean // true if the current schema... |
2,402 | function resolveSchema(
this: Ajv,
root: SchemaEnv, // root object with properties schema, refs TODO below SchemaEnv is assigned to it
ref: string // reference to resolve
): SchemaEnv | undefined {
const p = this.opts.uriResolver.parse(ref)
const refPath = _getFullPath(this.opts.uriResolver, p)
let baseId =... | class Ajv {
opts: InstanceOptions
errors?: ErrorObject[] | null // errors from the last validation
logger: Logger
// shared external scope values for compiled functions
readonly scope: ValueScope
readonly schemas: {[Key in string]?: SchemaEnv} = {}
readonly refs: {[Ref in string]?: SchemaEnv | string} = {... |
2,403 | function resolveSchema(
this: Ajv,
root: SchemaEnv, // root object with properties schema, refs TODO below SchemaEnv is assigned to it
ref: string // reference to resolve
): SchemaEnv | undefined {
const p = this.opts.uriResolver.parse(ref)
const refPath = _getFullPath(this.opts.uriResolver, p)
let baseId =... | class Ajv extends AjvCore {
constructor(opts: JTDOptions = {}) {
super({
...opts,
jtd: true,
})
}
_addVocabularies(): void {
super._addVocabularies()
this.addVocabulary(jtdVocabulary)
}
_addDefaultMetaSchema(): void {
super._addDefaultMetaSchema()
if (!this.opts.meta) ret... |
2,404 | function resolveSchema(
this: Ajv,
root: SchemaEnv, // root object with properties schema, refs TODO below SchemaEnv is assigned to it
ref: string // reference to resolve
): SchemaEnv | undefined {
const p = this.opts.uriResolver.parse(ref)
const refPath = _getFullPath(this.opts.uriResolver, p)
let baseId =... | class Ajv extends AjvCore {
_addVocabularies(): void {
super._addVocabularies()
draft7Vocabularies.forEach((v) => this.addVocabulary(v))
if (this.opts.discriminator) this.addKeyword(discriminator)
}
_addDefaultMetaSchema(): void {
super._addDefaultMetaSchema()
if (!this.opts.meta) return
... |
2,405 | function getJsonPointer(
this: Ajv,
parsedRef: URI.URIComponents,
{baseId, schema, root}: SchemaEnv
): SchemaEnv | undefined {
if (parsedRef.fragment?.[0] !== "/") return
for (const part of parsedRef.fragment.slice(1).split("/")) {
if (typeof schema === "boolean") return
const partSchema = schema[unes... | class SchemaEnv implements SchemaEnvArgs {
readonly schema: AnySchema
readonly schemaId?: "$id" | "id"
readonly root: SchemaEnv
baseId: string // TODO possibly, it should be readonly
schemaPath?: string
localRefs?: LocalRefs
readonly meta?: boolean
readonly $async?: boolean // true if the current schema... |
2,406 | function getJsonPointer(
this: Ajv,
parsedRef: URI.URIComponents,
{baseId, schema, root}: SchemaEnv
): SchemaEnv | undefined {
if (parsedRef.fragment?.[0] !== "/") return
for (const part of parsedRef.fragment.slice(1).split("/")) {
if (typeof schema === "boolean") return
const partSchema = schema[unes... | class Ajv {
opts: InstanceOptions
errors?: ErrorObject[] | null // errors from the last validation
logger: Logger
// shared external scope values for compiled functions
readonly scope: ValueScope
readonly schemas: {[Key in string]?: SchemaEnv} = {}
readonly refs: {[Ref in string]?: SchemaEnv | string} = {... |
2,407 | function getJsonPointer(
this: Ajv,
parsedRef: URI.URIComponents,
{baseId, schema, root}: SchemaEnv
): SchemaEnv | undefined {
if (parsedRef.fragment?.[0] !== "/") return
for (const part of parsedRef.fragment.slice(1).split("/")) {
if (typeof schema === "boolean") return
const partSchema = schema[unes... | class Ajv extends AjvCore {
constructor(opts: JTDOptions = {}) {
super({
...opts,
jtd: true,
})
}
_addVocabularies(): void {
super._addVocabularies()
this.addVocabulary(jtdVocabulary)
}
_addDefaultMetaSchema(): void {
super._addDefaultMetaSchema()
if (!this.opts.meta) ret... |
2,408 | function getJsonPointer(
this: Ajv,
parsedRef: URI.URIComponents,
{baseId, schema, root}: SchemaEnv
): SchemaEnv | undefined {
if (parsedRef.fragment?.[0] !== "/") return
for (const part of parsedRef.fragment.slice(1).split("/")) {
if (typeof schema === "boolean") return
const partSchema = schema[unes... | class Ajv extends AjvCore {
_addVocabularies(): void {
super._addVocabularies()
draft7Vocabularies.forEach((v) => this.addVocabulary(v))
if (this.opts.discriminator) this.addKeyword(discriminator)
}
_addDefaultMetaSchema(): void {
super._addDefaultMetaSchema()
if (!this.opts.meta) return
... |
2,409 | constructor(resolver: UriResolver, baseId: string, ref: string, msg?: string) {
super(msg || `can't resolve reference ${ref} from id ${baseId}`)
this.missingRef = resolveUrl(resolver, baseId, ref)
this.missingSchema = normalizeId(getFullPath(resolver, this.missingRef))
} | interface UriResolver {
parse(uri: string): URI.URIComponents
resolve(base: string, path: string): string
serialize(component: URI.URIComponents): string
} |
2,410 | function alwaysValidSchema(it: SchemaCxt, schema: AnySchema): boolean | void {
if (typeof schema == "boolean") return schema
if (Object.keys(schema).length === 0) return true
checkUnknownRules(it, schema)
return !schemaHasRules(schema, it.self.RULES.all)
} | type AnySchema = Schema | AsyncSchema |
2,411 | function alwaysValidSchema(it: SchemaCxt, schema: AnySchema): boolean | void {
if (typeof schema == "boolean") return schema
if (Object.keys(schema).length === 0) return true
checkUnknownRules(it, schema)
return !schemaHasRules(schema, it.self.RULES.all)
} | interface SchemaCxt {
readonly gen: CodeGen
readonly allErrors?: boolean // validation mode - whether to collect all errors or break on error
readonly data: Name // Name with reference to the current part of data instance
readonly parentData: Name // should be used in keywords modifying data
readonly parentDa... |
2,412 | function checkUnknownRules(it: SchemaCxt, schema: AnySchema = it.schema): void {
const {opts, self} = it
if (!opts.strictSchema) return
if (typeof schema === "boolean") return
const rules = self.RULES.keywords
for (const key in schema) {
if (!rules[key]) checkStrictMode(it, `unknown keyword: "${key}"`)
... | type AnySchema = Schema | AsyncSchema |
2,413 | function checkUnknownRules(it: SchemaCxt, schema: AnySchema = it.schema): void {
const {opts, self} = it
if (!opts.strictSchema) return
if (typeof schema === "boolean") return
const rules = self.RULES.keywords
for (const key in schema) {
if (!rules[key]) checkStrictMode(it, `unknown keyword: "${key}"`)
... | interface SchemaCxt {
readonly gen: CodeGen
readonly allErrors?: boolean // validation mode - whether to collect all errors or break on error
readonly data: Name // Name with reference to the current part of data instance
readonly parentData: Name // should be used in keywords modifying data
readonly parentDa... |
2,414 | function schemaHasRules(
schema: AnySchema,
rules: {[Key in string]?: boolean | Rule}
): boolean {
if (typeof schema == "boolean") return !schema
for (const key in schema) if (rules[key]) return true
return false
} | type AnySchema = Schema | AsyncSchema |
2,415 | function schemaHasRulesButRef(schema: AnySchema, RULES: ValidationRules): boolean {
if (typeof schema == "boolean") return !schema
for (const key in schema) if (key !== "$ref" && RULES.all[key]) return true
return false
} | interface ValidationRules {
rules: RuleGroup[]
post: RuleGroup
all: {[Key in string]?: boolean | Rule} // rules that have to be validated
keywords: {[Key in string]?: boolean} // all known keywords (superset of "all")
types: ValidationTypes
} |
2,416 | function schemaHasRulesButRef(schema: AnySchema, RULES: ValidationRules): boolean {
if (typeof schema == "boolean") return !schema
for (const key in schema) if (key !== "$ref" && RULES.all[key]) return true
return false
} | type AnySchema = Schema | AsyncSchema |
2,417 | function schemaRefOrVal(
{topSchemaRef, schemaPath}: SchemaObjCxt,
schema: unknown,
keyword: string,
$data?: string | false
): Code | number | boolean {
if (!$data) {
if (typeof schema == "number" || typeof schema == "boolean") return schema
if (typeof schema == "string") return _`${schema}`
}
ret... | interface SchemaObjCxt extends SchemaCxt {
readonly schema: AnySchemaObject
} |
2,418 | (
gen: CodeGen,
from: Name | T,
to: Name | Exclude<T, true> | undefined,
toName?: typeof Name
) => Name | T | class CodeGen {
readonly _scope: Scope
readonly _extScope: ValueScope
readonly _values: ScopeValueSets = {}
private readonly _nodes: ParentNode[]
private readonly _blockStarts: number[] = []
private readonly _constants: Constants = {}
private readonly opts: CGOptions
constructor(extScope: ValueScope, o... |
2,419 | (gen: CodeGen, from: Name, to: Name) => void | class Name extends _CodeOrName {
readonly str: string
constructor(s: string) {
super()
if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier")
this.str = s
}
toString(): string {
return this.str
}
emptyStr(): boolean {
return false
}
get names(): UsedN... |
2,420 | (gen: CodeGen, from: Name, to: Name) => void | class CodeGen {
readonly _scope: Scope
readonly _extScope: ValueScope
readonly _values: ScopeValueSets = {}
private readonly _nodes: ParentNode[]
private readonly _blockStarts: number[] = []
private readonly _constants: Constants = {}
private readonly opts: CGOptions
constructor(extScope: ValueScope, o... |
2,421 | (gen: CodeGen, from: T, to: Name) => void | class Name extends _CodeOrName {
readonly str: string
constructor(s: string) {
super()
if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier")
this.str = s
}
toString(): string {
return this.str
}
emptyStr(): boolean {
return false
}
get names(): UsedN... |
2,422 | (gen: CodeGen, from: T, to: Name) => void | class CodeGen {
readonly _scope: Scope
readonly _extScope: ValueScope
readonly _values: ScopeValueSets = {}
private readonly _nodes: ParentNode[]
private readonly _blockStarts: number[] = []
private readonly _constants: Constants = {}
private readonly opts: CGOptions
constructor(extScope: ValueScope, o... |
2,423 | (gen: CodeGen, res?: T) => Name | class CodeGen {
readonly _scope: Scope
readonly _extScope: ValueScope
readonly _values: ScopeValueSets = {}
private readonly _nodes: ParentNode[]
private readonly _blockStarts: number[] = []
private readonly _constants: Constants = {}
private readonly opts: CGOptions
constructor(extScope: ValueScope, o... |
2,424 | function evaluatedPropsToName(gen: CodeGen, ps?: EvaluatedProperties): Name {
if (ps === true) return gen.var("props", true)
const props = gen.var("props", _`{}`)
if (ps !== undefined) setEvaluated(gen, props, ps)
return props
} | type EvaluatedProperties = {[K in string]?: true} | true |
2,425 | function evaluatedPropsToName(gen: CodeGen, ps?: EvaluatedProperties): Name {
if (ps === true) return gen.var("props", true)
const props = gen.var("props", _`{}`)
if (ps !== undefined) setEvaluated(gen, props, ps)
return props
} | class CodeGen {
readonly _scope: Scope
readonly _extScope: ValueScope
readonly _values: ScopeValueSets = {}
private readonly _nodes: ParentNode[]
private readonly _blockStarts: number[] = []
private readonly _constants: Constants = {}
private readonly opts: CGOptions
constructor(extScope: ValueScope, o... |
2,426 | function setEvaluated(gen: CodeGen, props: Name, ps: {[K in string]?: true}): void {
Object.keys(ps).forEach((p) => gen.assign(_`${props}${getProperty(p)}`, true))
} | class Name extends _CodeOrName {
readonly str: string
constructor(s: string) {
super()
if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier")
this.str = s
}
toString(): string {
return this.str
}
emptyStr(): boolean {
return false
}
get names(): UsedN... |
2,427 | function setEvaluated(gen: CodeGen, props: Name, ps: {[K in string]?: true}): void {
Object.keys(ps).forEach((p) => gen.assign(_`${props}${getProperty(p)}`, true))
} | class CodeGen {
readonly _scope: Scope
readonly _extScope: ValueScope
readonly _values: ScopeValueSets = {}
private readonly _nodes: ParentNode[]
private readonly _blockStarts: number[] = []
private readonly _constants: Constants = {}
private readonly opts: CGOptions
constructor(extScope: ValueScope, o... |
2,428 | function useFunc(gen: CodeGen, f: {code: string}): Name {
return gen.scopeValue("func", {
ref: f,
code: snippets[f.code] || (snippets[f.code] = new _Code(f.code)),
})
} | class CodeGen {
readonly _scope: Scope
readonly _extScope: ValueScope
readonly _values: ScopeValueSets = {}
private readonly _nodes: ParentNode[]
private readonly _blockStarts: number[] = []
private readonly _constants: Constants = {}
private readonly opts: CGOptions
constructor(extScope: ValueScope, o... |
2,429 | function checkStrictMode(
it: SchemaCxt,
msg: string,
mode: boolean | "log" = it.opts.strictSchema
): void {
if (!mode) return
msg = `strict mode: ${msg}`
if (mode === true) throw new Error(msg)
it.self.logger.warn(msg)
} | interface SchemaCxt {
readonly gen: CodeGen
readonly allErrors?: boolean // validation mode - whether to collect all errors or break on error
readonly data: Name // Name with reference to the current part of data instance
readonly parentData: Name // should be used in keywords modifying data
readonly parentDa... |
2,430 | function reportError(
cxt: KeywordErrorCxt,
error: KeywordErrorDefinition = keywordError,
errorPaths?: ErrorPaths,
overrideAllErrors?: boolean
): void {
const {it} = cxt
const {gen, compositeRule, allErrors} = it
const errObj = errorObjectCode(cxt, error, errorPaths)
if (overrideAllErrors ?? (compositeR... | interface KeywordErrorDefinition {
message: string | Code | ((cxt: KeywordErrorCxt) => string | Code)
params?: Code | ((cxt: KeywordErrorCxt) => Code)
} |
2,431 | function reportError(
cxt: KeywordErrorCxt,
error: KeywordErrorDefinition = keywordError,
errorPaths?: ErrorPaths,
overrideAllErrors?: boolean
): void {
const {it} = cxt
const {gen, compositeRule, allErrors} = it
const errObj = errorObjectCode(cxt, error, errorPaths)
if (overrideAllErrors ?? (compositeR... | interface KeywordErrorCxt {
gen: CodeGen
keyword: string
data: Name
$data?: string | false
schema: any // TODO
parentSchema?: AnySchemaObject
schemaCode: Code | number | boolean
schemaValue: Code | number | boolean
schemaType?: JSONType[]
errsCount?: Name
params: KeywordCxtParams
it: SchemaCxt
} |
2,432 | function reportError(
cxt: KeywordErrorCxt,
error: KeywordErrorDefinition = keywordError,
errorPaths?: ErrorPaths,
overrideAllErrors?: boolean
): void {
const {it} = cxt
const {gen, compositeRule, allErrors} = it
const errObj = errorObjectCode(cxt, error, errorPaths)
if (overrideAllErrors ?? (compositeR... | interface ErrorPaths {
instancePath?: Code
schemaPath?: string
parentSchema?: boolean
} |
2,433 | function reportExtraError(
cxt: KeywordErrorCxt,
error: KeywordErrorDefinition = keywordError,
errorPaths?: ErrorPaths
): void {
const {it} = cxt
const {gen, compositeRule, allErrors} = it
const errObj = errorObjectCode(cxt, error, errorPaths)
addError(gen, errObj)
if (!(compositeRule || allErrors)) {
... | interface KeywordErrorDefinition {
message: string | Code | ((cxt: KeywordErrorCxt) => string | Code)
params?: Code | ((cxt: KeywordErrorCxt) => Code)
} |
2,434 | function reportExtraError(
cxt: KeywordErrorCxt,
error: KeywordErrorDefinition = keywordError,
errorPaths?: ErrorPaths
): void {
const {it} = cxt
const {gen, compositeRule, allErrors} = it
const errObj = errorObjectCode(cxt, error, errorPaths)
addError(gen, errObj)
if (!(compositeRule || allErrors)) {
... | interface KeywordErrorCxt {
gen: CodeGen
keyword: string
data: Name
$data?: string | false
schema: any // TODO
parentSchema?: AnySchemaObject
schemaCode: Code | number | boolean
schemaValue: Code | number | boolean
schemaType?: JSONType[]
errsCount?: Name
params: KeywordCxtParams
it: SchemaCxt
} |
2,435 | function reportExtraError(
cxt: KeywordErrorCxt,
error: KeywordErrorDefinition = keywordError,
errorPaths?: ErrorPaths
): void {
const {it} = cxt
const {gen, compositeRule, allErrors} = it
const errObj = errorObjectCode(cxt, error, errorPaths)
addError(gen, errObj)
if (!(compositeRule || allErrors)) {
... | interface ErrorPaths {
instancePath?: Code
schemaPath?: string
parentSchema?: boolean
} |
2,436 | function resetErrorsCount(gen: CodeGen, errsCount: Name): void {
gen.assign(N.errors, errsCount)
gen.if(_`${N.vErrors} !== null`, () =>
gen.if(
errsCount,
() => gen.assign(_`${N.vErrors}.length`, errsCount),
() => gen.assign(N.vErrors, null)
)
)
} | class Name extends _CodeOrName {
readonly str: string
constructor(s: string) {
super()
if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier")
this.str = s
}
toString(): string {
return this.str
}
emptyStr(): boolean {
return false
}
get names(): UsedN... |
2,437 | function resetErrorsCount(gen: CodeGen, errsCount: Name): void {
gen.assign(N.errors, errsCount)
gen.if(_`${N.vErrors} !== null`, () =>
gen.if(
errsCount,
() => gen.assign(_`${N.vErrors}.length`, errsCount),
() => gen.assign(N.vErrors, null)
)
)
} | class CodeGen {
readonly _scope: Scope
readonly _extScope: ValueScope
readonly _values: ScopeValueSets = {}
private readonly _nodes: ParentNode[]
private readonly _blockStarts: number[] = []
private readonly _constants: Constants = {}
private readonly opts: CGOptions
constructor(extScope: ValueScope, o... |
2,438 | function extendErrors({
gen,
keyword,
schemaValue,
data,
errsCount,
it,
}: KeywordErrorCxt): void {
/* istanbul ignore if */
if (errsCount === undefined) throw new Error("ajv implementation error")
const err = gen.name("err")
gen.forRange("i", errsCount, N.errors, (i) => {
gen.const(err, _`${N.v... | interface KeywordErrorCxt {
gen: CodeGen
keyword: string
data: Name
$data?: string | false
schema: any // TODO
parentSchema?: AnySchemaObject
schemaCode: Code | number | boolean
schemaValue: Code | number | boolean
schemaType?: JSONType[]
errsCount?: Name
params: KeywordCxtParams
it: SchemaCxt
} |
2,439 | function addError(gen: CodeGen, errObj: Code): void {
const err = gen.const("err", errObj)
gen.if(
_`${N.vErrors} === null`,
() => gen.assign(N.vErrors, _`[${err}]`),
_`${N.vErrors}.push(${err})`
)
gen.code(_`${N.errors}++`)
} | type Code = _Code | Name |
2,440 | function addError(gen: CodeGen, errObj: Code): void {
const err = gen.const("err", errObj)
gen.if(
_`${N.vErrors} === null`,
() => gen.assign(N.vErrors, _`[${err}]`),
_`${N.vErrors}.push(${err})`
)
gen.code(_`${N.errors}++`)
} | class CodeGen {
readonly _scope: Scope
readonly _extScope: ValueScope
readonly _values: ScopeValueSets = {}
private readonly _nodes: ParentNode[]
private readonly _blockStarts: number[] = []
private readonly _constants: Constants = {}
private readonly opts: CGOptions
constructor(extScope: ValueScope, o... |
2,441 | function returnErrors(it: SchemaCxt, errs: Code): void {
const {gen, validateName, schemaEnv} = it
if (schemaEnv.$async) {
gen.throw(_`new ${it.ValidationError as Name}(${errs})`)
} else {
gen.assign(_`${validateName}.errors`, errs)
gen.return(false)
}
} | interface SchemaCxt {
readonly gen: CodeGen
readonly allErrors?: boolean // validation mode - whether to collect all errors or break on error
readonly data: Name // Name with reference to the current part of data instance
readonly parentData: Name // should be used in keywords modifying data
readonly parentDa... |
2,442 | function returnErrors(it: SchemaCxt, errs: Code): void {
const {gen, validateName, schemaEnv} = it
if (schemaEnv.$async) {
gen.throw(_`new ${it.ValidationError as Name}(${errs})`)
} else {
gen.assign(_`${validateName}.errors`, errs)
gen.return(false)
}
} | type Code = _Code | Name |
2,443 | function errorObjectCode(
cxt: KeywordErrorCxt,
error: KeywordErrorDefinition,
errorPaths?: ErrorPaths
): Code {
const {createErrors} = cxt.it
if (createErrors === false) return _`{}`
return errorObject(cxt, error, errorPaths)
} | interface KeywordErrorDefinition {
message: string | Code | ((cxt: KeywordErrorCxt) => string | Code)
params?: Code | ((cxt: KeywordErrorCxt) => Code)
} |
2,444 | function errorObjectCode(
cxt: KeywordErrorCxt,
error: KeywordErrorDefinition,
errorPaths?: ErrorPaths
): Code {
const {createErrors} = cxt.it
if (createErrors === false) return _`{}`
return errorObject(cxt, error, errorPaths)
} | interface KeywordErrorCxt {
gen: CodeGen
keyword: string
data: Name
$data?: string | false
schema: any // TODO
parentSchema?: AnySchemaObject
schemaCode: Code | number | boolean
schemaValue: Code | number | boolean
schemaType?: JSONType[]
errsCount?: Name
params: KeywordCxtParams
it: SchemaCxt
} |
2,445 | function errorObjectCode(
cxt: KeywordErrorCxt,
error: KeywordErrorDefinition,
errorPaths?: ErrorPaths
): Code {
const {createErrors} = cxt.it
if (createErrors === false) return _`{}`
return errorObject(cxt, error, errorPaths)
} | interface ErrorPaths {
instancePath?: Code
schemaPath?: string
parentSchema?: boolean
} |
2,446 | function errorObject(
cxt: KeywordErrorCxt,
error: KeywordErrorDefinition,
errorPaths: ErrorPaths = {}
): Code {
const {gen, it} = cxt
const keyValues: [Name, SafeExpr | string][] = [
errorInstancePath(it, errorPaths),
errorSchemaPath(cxt, errorPaths),
]
extraErrorProps(cxt, error, keyValues)
re... | interface KeywordErrorDefinition {
message: string | Code | ((cxt: KeywordErrorCxt) => string | Code)
params?: Code | ((cxt: KeywordErrorCxt) => Code)
} |
2,447 | function errorObject(
cxt: KeywordErrorCxt,
error: KeywordErrorDefinition,
errorPaths: ErrorPaths = {}
): Code {
const {gen, it} = cxt
const keyValues: [Name, SafeExpr | string][] = [
errorInstancePath(it, errorPaths),
errorSchemaPath(cxt, errorPaths),
]
extraErrorProps(cxt, error, keyValues)
re... | interface KeywordErrorCxt {
gen: CodeGen
keyword: string
data: Name
$data?: string | false
schema: any // TODO
parentSchema?: AnySchemaObject
schemaCode: Code | number | boolean
schemaValue: Code | number | boolean
schemaType?: JSONType[]
errsCount?: Name
params: KeywordCxtParams
it: SchemaCxt
} |
2,448 | function errorObject(
cxt: KeywordErrorCxt,
error: KeywordErrorDefinition,
errorPaths: ErrorPaths = {}
): Code {
const {gen, it} = cxt
const keyValues: [Name, SafeExpr | string][] = [
errorInstancePath(it, errorPaths),
errorSchemaPath(cxt, errorPaths),
]
extraErrorProps(cxt, error, keyValues)
re... | interface ErrorPaths {
instancePath?: Code
schemaPath?: string
parentSchema?: boolean
} |
2,449 | function errorInstancePath({errorPath}: SchemaCxt, {instancePath}: ErrorPaths): [Name, Code] {
const instPath = instancePath
? str`${errorPath}${getErrorPath(instancePath, Type.Str)}`
: errorPath
return [N.instancePath, strConcat(N.instancePath, instPath)]
} | interface SchemaCxt {
readonly gen: CodeGen
readonly allErrors?: boolean // validation mode - whether to collect all errors or break on error
readonly data: Name // Name with reference to the current part of data instance
readonly parentData: Name // should be used in keywords modifying data
readonly parentDa... |
2,450 | function errorInstancePath({errorPath}: SchemaCxt, {instancePath}: ErrorPaths): [Name, Code] {
const instPath = instancePath
? str`${errorPath}${getErrorPath(instancePath, Type.Str)}`
: errorPath
return [N.instancePath, strConcat(N.instancePath, instPath)]
} | interface ErrorPaths {
instancePath?: Code
schemaPath?: string
parentSchema?: boolean
} |
2,451 | function errorSchemaPath(
{keyword, it: {errSchemaPath}}: KeywordErrorCxt,
{schemaPath, parentSchema}: ErrorPaths
): [Name, string | Code] {
let schPath = parentSchema ? errSchemaPath : str`${errSchemaPath}/${keyword}`
if (schemaPath) {
schPath = str`${schPath}${getErrorPath(schemaPath, Type.Str)}`
}
re... | interface KeywordErrorCxt {
gen: CodeGen
keyword: string
data: Name
$data?: string | false
schema: any // TODO
parentSchema?: AnySchemaObject
schemaCode: Code | number | boolean
schemaValue: Code | number | boolean
schemaType?: JSONType[]
errsCount?: Name
params: KeywordCxtParams
it: SchemaCxt
} |
2,452 | function errorSchemaPath(
{keyword, it: {errSchemaPath}}: KeywordErrorCxt,
{schemaPath, parentSchema}: ErrorPaths
): [Name, string | Code] {
let schPath = parentSchema ? errSchemaPath : str`${errSchemaPath}/${keyword}`
if (schemaPath) {
schPath = str`${schPath}${getErrorPath(schemaPath, Type.Str)}`
}
re... | interface ErrorPaths {
instancePath?: Code
schemaPath?: string
parentSchema?: boolean
} |
2,453 | function extraErrorProps(
cxt: KeywordErrorCxt,
{params, message}: KeywordErrorDefinition,
keyValues: [Name, SafeExpr | string][]
): void {
const {keyword, data, schemaValue, it} = cxt
const {opts, propertyName, topSchemaRef, schemaPath} = it
keyValues.push(
[E.keyword, keyword],
[E.params, typeof p... | interface KeywordErrorDefinition {
message: string | Code | ((cxt: KeywordErrorCxt) => string | Code)
params?: Code | ((cxt: KeywordErrorCxt) => Code)
} |
2,454 | function extraErrorProps(
cxt: KeywordErrorCxt,
{params, message}: KeywordErrorDefinition,
keyValues: [Name, SafeExpr | string][]
): void {
const {keyword, data, schemaValue, it} = cxt
const {opts, propertyName, topSchemaRef, schemaPath} = it
keyValues.push(
[E.keyword, keyword],
[E.params, typeof p... | interface KeywordErrorCxt {
gen: CodeGen
keyword: string
data: Name
$data?: string | false
schema: any // TODO
parentSchema?: AnySchemaObject
schemaCode: Code | number | boolean
schemaValue: Code | number | boolean
schemaType?: JSONType[]
errsCount?: Name
params: KeywordCxtParams
it: SchemaCxt
} |
2,455 | function inlineRef(schema: AnySchema, limit: boolean | number = true): boolean {
if (typeof schema == "boolean") return true
if (limit === true) return !hasRef(schema)
if (!limit) return false
return countKeys(schema) <= limit
} | type AnySchema = Schema | AsyncSchema |
2,456 | function hasRef(schema: AnySchemaObject): boolean {
for (const key in schema) {
if (REF_KEYWORDS.has(key)) return true
const sch = schema[key]
if (Array.isArray(sch) && sch.some(hasRef)) return true
if (typeof sch == "object" && hasRef(sch)) return true
}
return false
} | type AnySchemaObject = SchemaObject | AsyncSchema |
2,457 | function countKeys(schema: AnySchemaObject): number {
let count = 0
for (const key in schema) {
if (key === "$ref") return Infinity
count++
if (SIMPLE_INLINED.has(key)) continue
if (typeof schema[key] == "object") {
eachItem(schema[key], (sch) => (count += countKeys(sch)))
}
if (count ... | type AnySchemaObject = SchemaObject | AsyncSchema |
2,458 | function getFullPath(resolver: UriResolver, id = "", normalize?: boolean): string {
if (normalize !== false) id = normalizeId(id)
const p = resolver.parse(id)
return _getFullPath(resolver, p)
} | interface UriResolver {
parse(uri: string): URI.URIComponents
resolve(base: string, path: string): string
serialize(component: URI.URIComponents): string
} |
2,459 | function _getFullPath(resolver: UriResolver, p: URIComponents): string {
const serialized = resolver.serialize(p)
return serialized.split("#")[0] + "#"
} | interface UriResolver {
parse(uri: string): URI.URIComponents
resolve(base: string, path: string): string
serialize(component: URI.URIComponents): string
} |
2,460 | function resolveUrl(resolver: UriResolver, baseId: string, id: string): string {
id = normalizeId(id)
return resolver.resolve(baseId, id)
} | interface UriResolver {
parse(uri: string): URI.URIComponents
resolve(base: string, path: string): string
serialize(component: URI.URIComponents): string
} |
2,461 | function getSchemaRefs(this: Ajv, schema: AnySchema, baseId: string): LocalRefs {
if (typeof schema == "boolean") return {}
const {schemaId, uriResolver} = this.opts
const schId = normalizeId(schema[schemaId] || baseId)
const baseIds: {[JsonPtr in string]?: string} = {"": schId}
const pathPrefix = getFullPath... | class Ajv {
opts: InstanceOptions
errors?: ErrorObject[] | null // errors from the last validation
logger: Logger
// shared external scope values for compiled functions
readonly scope: ValueScope
readonly schemas: {[Key in string]?: SchemaEnv} = {}
readonly refs: {[Ref in string]?: SchemaEnv | string} = {... |
2,462 | function getSchemaRefs(this: Ajv, schema: AnySchema, baseId: string): LocalRefs {
if (typeof schema == "boolean") return {}
const {schemaId, uriResolver} = this.opts
const schId = normalizeId(schema[schemaId] || baseId)
const baseIds: {[JsonPtr in string]?: string} = {"": schId}
const pathPrefix = getFullPath... | class Ajv extends AjvCore {
constructor(opts: JTDOptions = {}) {
super({
...opts,
jtd: true,
})
}
_addVocabularies(): void {
super._addVocabularies()
this.addVocabulary(jtdVocabulary)
}
_addDefaultMetaSchema(): void {
super._addDefaultMetaSchema()
if (!this.opts.meta) ret... |
2,463 | function getSchemaRefs(this: Ajv, schema: AnySchema, baseId: string): LocalRefs {
if (typeof schema == "boolean") return {}
const {schemaId, uriResolver} = this.opts
const schId = normalizeId(schema[schemaId] || baseId)
const baseIds: {[JsonPtr in string]?: string} = {"": schId}
const pathPrefix = getFullPath... | class Ajv extends AjvCore {
_addVocabularies(): void {
super._addVocabularies()
draft7Vocabularies.forEach((v) => this.addVocabulary(v))
if (this.opts.discriminator) this.addKeyword(discriminator)
}
_addDefaultMetaSchema(): void {
super._addDefaultMetaSchema()
if (!this.opts.meta) return
... |
2,464 | function getSchemaRefs(this: Ajv, schema: AnySchema, baseId: string): LocalRefs {
if (typeof schema == "boolean") return {}
const {schemaId, uriResolver} = this.opts
const schId = normalizeId(schema[schemaId] || baseId)
const baseIds: {[JsonPtr in string]?: string} = {"": schId}
const pathPrefix = getFullPath... | type AnySchema = Schema | AsyncSchema |
2,465 | function addRef(this: Ajv, ref: string): string {
// eslint-disable-next-line @typescript-eslint/unbound-method
const _resolve = this.opts.uriResolver.resolve
ref = normalizeId(baseId ? _resolve(baseId, ref) : ref)
if (schemaRefs.has(ref)) throw ambiguos(ref)
schemaRefs.add(ref)
let ... | class Ajv {
opts: InstanceOptions
errors?: ErrorObject[] | null // errors from the last validation
logger: Logger
// shared external scope values for compiled functions
readonly scope: ValueScope
readonly schemas: {[Key in string]?: SchemaEnv} = {}
readonly refs: {[Ref in string]?: SchemaEnv | string} = {... |
2,466 | function addRef(this: Ajv, ref: string): string {
// eslint-disable-next-line @typescript-eslint/unbound-method
const _resolve = this.opts.uriResolver.resolve
ref = normalizeId(baseId ? _resolve(baseId, ref) : ref)
if (schemaRefs.has(ref)) throw ambiguos(ref)
schemaRefs.add(ref)
let ... | class Ajv extends AjvCore {
constructor(opts: JTDOptions = {}) {
super({
...opts,
jtd: true,
})
}
_addVocabularies(): void {
super._addVocabularies()
this.addVocabulary(jtdVocabulary)
}
_addDefaultMetaSchema(): void {
super._addDefaultMetaSchema()
if (!this.opts.meta) ret... |
2,467 | function addRef(this: Ajv, ref: string): string {
// eslint-disable-next-line @typescript-eslint/unbound-method
const _resolve = this.opts.uriResolver.resolve
ref = normalizeId(baseId ? _resolve(baseId, ref) : ref)
if (schemaRefs.has(ref)) throw ambiguos(ref)
schemaRefs.add(ref)
let ... | class Ajv extends AjvCore {
_addVocabularies(): void {
super._addVocabularies()
draft7Vocabularies.forEach((v) => this.addVocabulary(v))
if (this.opts.discriminator) this.addKeyword(discriminator)
}
_addDefaultMetaSchema(): void {
super._addDefaultMetaSchema()
if (!this.opts.meta) return
... |
2,468 | function addAnchor(this: Ajv, anchor: unknown): void {
if (typeof anchor == "string") {
if (!ANCHOR.test(anchor)) throw new Error(`invalid anchor "${anchor}"`)
addRef.call(this, `#${anchor}`)
}
} | class Ajv {
opts: InstanceOptions
errors?: ErrorObject[] | null // errors from the last validation
logger: Logger
// shared external scope values for compiled functions
readonly scope: ValueScope
readonly schemas: {[Key in string]?: SchemaEnv} = {}
readonly refs: {[Ref in string]?: SchemaEnv | string} = {... |
2,469 | function addAnchor(this: Ajv, anchor: unknown): void {
if (typeof anchor == "string") {
if (!ANCHOR.test(anchor)) throw new Error(`invalid anchor "${anchor}"`)
addRef.call(this, `#${anchor}`)
}
} | class Ajv extends AjvCore {
constructor(opts: JTDOptions = {}) {
super({
...opts,
jtd: true,
})
}
_addVocabularies(): void {
super._addVocabularies()
this.addVocabulary(jtdVocabulary)
}
_addDefaultMetaSchema(): void {
super._addDefaultMetaSchema()
if (!this.opts.meta) ret... |
2,470 | function addAnchor(this: Ajv, anchor: unknown): void {
if (typeof anchor == "string") {
if (!ANCHOR.test(anchor)) throw new Error(`invalid anchor "${anchor}"`)
addRef.call(this, `#${anchor}`)
}
} | class Ajv extends AjvCore {
_addVocabularies(): void {
super._addVocabularies()
draft7Vocabularies.forEach((v) => this.addVocabulary(v))
if (this.opts.discriminator) this.addKeyword(discriminator)
}
_addDefaultMetaSchema(): void {
super._addDefaultMetaSchema()
if (!this.opts.meta) return
... |
2,471 | function checkAmbiguosRef(sch1: AnySchema, sch2: AnySchema | undefined, ref: string): void {
if (sch2 !== undefined && !equal(sch1, sch2)) throw ambiguos(ref)
} | type AnySchema = Schema | AsyncSchema |
2,472 | function topBoolOrEmptySchema(it: SchemaCxt): void {
const {gen, schema, validateName} = it
if (schema === false) {
falseSchemaError(it, false)
} else if (typeof schema == "object" && schema.$async === true) {
gen.return(N.data)
} else {
gen.assign(_`${validateName}.errors`, null)
gen.return(tru... | interface SchemaCxt {
readonly gen: CodeGen
readonly allErrors?: boolean // validation mode - whether to collect all errors or break on error
readonly data: Name // Name with reference to the current part of data instance
readonly parentData: Name // should be used in keywords modifying data
readonly parentDa... |
2,473 | function boolOrEmptySchema(it: SchemaCxt, valid: Name): void {
const {gen, schema} = it
if (schema === false) {
gen.var(valid, false) // TODO var
falseSchemaError(it)
} else {
gen.var(valid, true) // TODO var
}
} | class Name extends _CodeOrName {
readonly str: string
constructor(s: string) {
super()
if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier")
this.str = s
}
toString(): string {
return this.str
}
emptyStr(): boolean {
return false
}
get names(): UsedN... |
2,474 | function boolOrEmptySchema(it: SchemaCxt, valid: Name): void {
const {gen, schema} = it
if (schema === false) {
gen.var(valid, false) // TODO var
falseSchemaError(it)
} else {
gen.var(valid, true) // TODO var
}
} | interface SchemaCxt {
readonly gen: CodeGen
readonly allErrors?: boolean // validation mode - whether to collect all errors or break on error
readonly data: Name // Name with reference to the current part of data instance
readonly parentData: Name // should be used in keywords modifying data
readonly parentDa... |
2,475 | function falseSchemaError(it: SchemaCxt, overrideAllErrors?: boolean): void {
const {gen, data} = it
// TODO maybe some other interface should be used for non-keyword validation errors...
const cxt: KeywordErrorCxt = {
gen,
keyword: "false schema",
data,
schema: false,
schemaCode: false,
s... | interface SchemaCxt {
readonly gen: CodeGen
readonly allErrors?: boolean // validation mode - whether to collect all errors or break on error
readonly data: Name // Name with reference to the current part of data instance
readonly parentData: Name // should be used in keywords modifying data
readonly parentDa... |
2,476 | function validateFunctionCode(it: SchemaCxt): void {
if (isSchemaObj(it)) {
checkKeywords(it)
if (schemaCxtHasRules(it)) {
topSchemaObjCode(it)
return
}
}
validateFunction(it, () => topBoolOrEmptySchema(it))
} | interface SchemaCxt {
readonly gen: CodeGen
readonly allErrors?: boolean // validation mode - whether to collect all errors or break on error
readonly data: Name // Name with reference to the current part of data instance
readonly parentData: Name // should be used in keywords modifying data
readonly parentDa... |
2,477 | function validateFunction(
{gen, validateName, schema, schemaEnv, opts}: SchemaCxt,
body: Block
): void {
if (opts.code.es5) {
gen.func(validateName, _`${N.data}, ${N.valCxt}`, schemaEnv.$async, () => {
gen.code(_`"use strict"; ${funcSourceUrl(schema, opts)}`)
destructureValCxtES5(gen, opts)
... | type Block = Code | (() => void) |
2,478 | function validateFunction(
{gen, validateName, schema, schemaEnv, opts}: SchemaCxt,
body: Block
): void {
if (opts.code.es5) {
gen.func(validateName, _`${N.data}, ${N.valCxt}`, schemaEnv.$async, () => {
gen.code(_`"use strict"; ${funcSourceUrl(schema, opts)}`)
destructureValCxtES5(gen, opts)
... | interface SchemaCxt {
readonly gen: CodeGen
readonly allErrors?: boolean // validation mode - whether to collect all errors or break on error
readonly data: Name // Name with reference to the current part of data instance
readonly parentData: Name // should be used in keywords modifying data
readonly parentDa... |
2,479 | function destructureValCxt(opts: InstanceOptions): Code {
return _`{${N.instancePath}="", ${N.parentData}, ${N.parentDataProperty}, ${N.rootData}=${
N.data
}${opts.dynamicRef ? _`, ${N.dynamicAnchors}={}` : nil}}={}`
} | type InstanceOptions = Options & RequiredInstanceOptions |
2,480 | function destructureValCxtES5(gen: CodeGen, opts: InstanceOptions): void {
gen.if(
N.valCxt,
() => {
gen.var(N.instancePath, _`${N.valCxt}.${N.instancePath}`)
gen.var(N.parentData, _`${N.valCxt}.${N.parentData}`)
gen.var(N.parentDataProperty, _`${N.valCxt}.${N.parentDataProperty}`)
gen... | class CodeGen {
readonly _scope: Scope
readonly _extScope: ValueScope
readonly _values: ScopeValueSets = {}
private readonly _nodes: ParentNode[]
private readonly _blockStarts: number[] = []
private readonly _constants: Constants = {}
private readonly opts: CGOptions
constructor(extScope: ValueScope, o... |
2,481 | function destructureValCxtES5(gen: CodeGen, opts: InstanceOptions): void {
gen.if(
N.valCxt,
() => {
gen.var(N.instancePath, _`${N.valCxt}.${N.instancePath}`)
gen.var(N.parentData, _`${N.valCxt}.${N.parentData}`)
gen.var(N.parentDataProperty, _`${N.valCxt}.${N.parentDataProperty}`)
gen... | type InstanceOptions = Options & RequiredInstanceOptions |
2,482 | function topSchemaObjCode(it: SchemaObjCxt): void {
const {schema, opts, gen} = it
validateFunction(it, () => {
if (opts.$comment && schema.$comment) commentKeyword(it)
checkNoDefault(it)
gen.let(N.vErrors, null)
gen.let(N.errors, 0)
if (opts.unevaluated) resetEvaluated(it)
typeAndKeywords(i... | interface SchemaObjCxt extends SchemaCxt {
readonly schema: AnySchemaObject
} |
2,483 | function resetEvaluated(it: SchemaObjCxt): void {
// TODO maybe some hook to execute it in the end to check whether props/items are Name, as in assignEvaluated
const {gen, validateName} = it
it.evaluated = gen.const("evaluated", _`${validateName}.evaluated`)
gen.if(_`${it.evaluated}.dynamicProps`, () => gen.ass... | interface SchemaObjCxt extends SchemaCxt {
readonly schema: AnySchemaObject
} |
2,484 | function funcSourceUrl(schema: AnySchema, opts: InstanceOptions): Code {
const schId = typeof schema == "object" && schema[opts.schemaId]
return schId && (opts.code.source || opts.code.process) ? _`/*# sourceURL=${schId} */` : nil
} | type AnySchema = Schema | AsyncSchema |
2,485 | function funcSourceUrl(schema: AnySchema, opts: InstanceOptions): Code {
const schId = typeof schema == "object" && schema[opts.schemaId]
return schId && (opts.code.source || opts.code.process) ? _`/*# sourceURL=${schId} */` : nil
} | type InstanceOptions = Options & RequiredInstanceOptions |
2,486 | function subschemaCode(it: SchemaCxt, valid: Name): void {
if (isSchemaObj(it)) {
checkKeywords(it)
if (schemaCxtHasRules(it)) {
subSchemaObjCode(it, valid)
return
}
}
boolOrEmptySchema(it, valid)
} | class Name extends _CodeOrName {
readonly str: string
constructor(s: string) {
super()
if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier")
this.str = s
}
toString(): string {
return this.str
}
emptyStr(): boolean {
return false
}
get names(): UsedN... |
2,487 | function subschemaCode(it: SchemaCxt, valid: Name): void {
if (isSchemaObj(it)) {
checkKeywords(it)
if (schemaCxtHasRules(it)) {
subSchemaObjCode(it, valid)
return
}
}
boolOrEmptySchema(it, valid)
} | interface SchemaCxt {
readonly gen: CodeGen
readonly allErrors?: boolean // validation mode - whether to collect all errors or break on error
readonly data: Name // Name with reference to the current part of data instance
readonly parentData: Name // should be used in keywords modifying data
readonly parentDa... |
2,488 | function schemaCxtHasRules({schema, self}: SchemaCxt): boolean {
if (typeof schema == "boolean") return !schema
for (const key in schema) if (self.RULES.all[key]) return true
return false
} | interface SchemaCxt {
readonly gen: CodeGen
readonly allErrors?: boolean // validation mode - whether to collect all errors or break on error
readonly data: Name // Name with reference to the current part of data instance
readonly parentData: Name // should be used in keywords modifying data
readonly parentDa... |
2,489 | function isSchemaObj(it: SchemaCxt): it is SchemaObjCxt {
return typeof it.schema != "boolean"
} | interface SchemaCxt {
readonly gen: CodeGen
readonly allErrors?: boolean // validation mode - whether to collect all errors or break on error
readonly data: Name // Name with reference to the current part of data instance
readonly parentData: Name // should be used in keywords modifying data
readonly parentDa... |
2,490 | function subSchemaObjCode(it: SchemaObjCxt, valid: Name): void {
const {schema, gen, opts} = it
if (opts.$comment && schema.$comment) commentKeyword(it)
updateContext(it)
checkAsyncSchema(it)
const errsCount = gen.const("_errs", N.errors)
typeAndKeywords(it, errsCount)
// TODO var
gen.var(valid, _`${err... | interface SchemaObjCxt extends SchemaCxt {
readonly schema: AnySchemaObject
} |
2,491 | function subSchemaObjCode(it: SchemaObjCxt, valid: Name): void {
const {schema, gen, opts} = it
if (opts.$comment && schema.$comment) commentKeyword(it)
updateContext(it)
checkAsyncSchema(it)
const errsCount = gen.const("_errs", N.errors)
typeAndKeywords(it, errsCount)
// TODO var
gen.var(valid, _`${err... | class Name extends _CodeOrName {
readonly str: string
constructor(s: string) {
super()
if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier")
this.str = s
}
toString(): string {
return this.str
}
emptyStr(): boolean {
return false
}
get names(): UsedN... |
2,492 | function checkKeywords(it: SchemaObjCxt): void {
checkUnknownRules(it)
checkRefsAndKeywords(it)
} | interface SchemaObjCxt extends SchemaCxt {
readonly schema: AnySchemaObject
} |
2,493 | function typeAndKeywords(it: SchemaObjCxt, errsCount?: Name): void {
if (it.opts.jtd) return schemaKeywords(it, [], false, errsCount)
const types = getSchemaTypes(it.schema)
const checkedTypes = coerceAndCheckDataType(it, types)
schemaKeywords(it, types, !checkedTypes, errsCount)
} | interface SchemaObjCxt extends SchemaCxt {
readonly schema: AnySchemaObject
} |
2,494 | function typeAndKeywords(it: SchemaObjCxt, errsCount?: Name): void {
if (it.opts.jtd) return schemaKeywords(it, [], false, errsCount)
const types = getSchemaTypes(it.schema)
const checkedTypes = coerceAndCheckDataType(it, types)
schemaKeywords(it, types, !checkedTypes, errsCount)
} | class Name extends _CodeOrName {
readonly str: string
constructor(s: string) {
super()
if (!IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier")
this.str = s
}
toString(): string {
return this.str
}
emptyStr(): boolean {
return false
}
get names(): UsedN... |
2,495 | function checkRefsAndKeywords(it: SchemaObjCxt): void {
const {schema, errSchemaPath, opts, self} = it
if (schema.$ref && opts.ignoreKeywordsWithRef && schemaHasRulesButRef(schema, self.RULES)) {
self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`)
}
} | interface SchemaObjCxt extends SchemaCxt {
readonly schema: AnySchemaObject
} |
2,496 | function checkNoDefault(it: SchemaObjCxt): void {
const {schema, opts} = it
if (schema.default !== undefined && opts.useDefaults && opts.strictSchema) {
checkStrictMode(it, "default is ignored in the schema root")
}
} | interface SchemaObjCxt extends SchemaCxt {
readonly schema: AnySchemaObject
} |
2,497 | function updateContext(it: SchemaObjCxt): void {
const schId = it.schema[it.opts.schemaId]
if (schId) it.baseId = resolveUrl(it.opts.uriResolver, it.baseId, schId)
} | interface SchemaObjCxt extends SchemaCxt {
readonly schema: AnySchemaObject
} |
2,498 | function checkAsyncSchema(it: SchemaObjCxt): void {
if (it.schema.$async && !it.schemaEnv.$async) throw new Error("async schema in sync schema")
} | interface SchemaObjCxt extends SchemaCxt {
readonly schema: AnySchemaObject
} |
2,499 | function commentKeyword({gen, schemaEnv, schema, errSchemaPath, opts}: SchemaObjCxt): void {
const msg = schema.$comment
if (opts.$comment === true) {
gen.code(_`${N.self}.logger.log(${msg})`)
} else if (typeof opts.$comment == "function") {
const schemaPath = str`${errSchemaPath}/$comment`
const root... | interface SchemaObjCxt extends SchemaCxt {
readonly schema: AnySchemaObject
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.