@@ -28,7 +28,7 @@ THE SOFTWARE.
2828
2929// deno-fmt-ignore-file
3030
31- import * as S from '../types/index.ts'
31+ import * as Schema from '../types/index.ts'
3232import type { TValidationError } from '../../error/index.ts'
3333import { Guard as G , EmitGuard as E } from '../../guard/index.ts'
3434
@@ -37,8 +37,8 @@ import { Guard as G, EmitGuard as E } from '../../guard/index.ts'
3737// ------------------------------------------------------------------
3838function HasUnevaluatedFromObject ( value : Record < PropertyKey , unknown > ) : boolean {
3939 return (
40- S . IsUnevaluatedItems ( value )
41- || S . IsUnevaluatedProperties ( value )
40+ Schema . IsUnevaluatedItems ( value )
41+ || Schema . IsUnevaluatedProperties ( value )
4242 || G . Keys ( value ) . some ( key => HasUnevaluatedFromUnknown ( value [ key ] ) )
4343 )
4444}
@@ -55,29 +55,11 @@ function HasUnevaluatedFromUnknown(value: unknown) {
5555export function HasUnevaluated ( context : Record < PropertyKey , unknown > , schema : unknown ) : boolean {
5656 return HasUnevaluatedFromUnknown ( schema ) || G . Keys ( context ) . some ( key => HasUnevaluatedFromUnknown ( context [ key ] ) )
5757}
58-
59- // ------------------------------------------------------------------
60- // BaseContext
61- // ------------------------------------------------------------------
62- export class BaseContext {
63- constructor (
64- protected readonly context : Record < PropertyKey , S . XSchema > ,
65- protected readonly schema : S . XSchema ,
66- ) { }
67- public GetContext ( ) : Record < PropertyKey , object | boolean > {
68- return this . context
69- }
70- public GetSchema ( ) : object | boolean {
71- return this . schema
72- }
73- }
7458// ------------------------------------------------------------------
7559// BuildContext
7660// ------------------------------------------------------------------
77- export class BuildContext extends BaseContext {
78- constructor ( context : Record < PropertyKey , S . XSchema > , schema : S . XSchema , private readonly hasUnevaluated : boolean ) {
79- super ( context , schema )
80- }
61+ export class BuildContext {
62+ constructor ( private readonly hasUnevaluated : boolean ) { }
8163 public UseUnevaluated ( ) : boolean {
8264 return this . hasUnevaluated
8365 }
@@ -87,21 +69,17 @@ export class BuildContext extends BaseContext {
8769 public AddKey ( key : string ) : string {
8870 return E . Call ( E . Member ( 'context' , 'AddKey' ) , [ key ] )
8971 }
90- public Clone ( ) : string {
91- return E . Call ( E . Member ( 'context' , 'Clone' ) , [ ] )
92- }
9372 public Merge ( results : string ) : string {
9473 return E . Call ( E . Member ( 'context' , 'Merge' ) , [ results ] )
9574 }
9675}
9776// ------------------------------------------------------------------
9877// CheckContext
9978// ------------------------------------------------------------------
100- export class CheckContext extends BaseContext {
79+ export class CheckContext {
10180 private readonly indices : Set < number >
10281 private readonly keys : Set < string >
103- constructor ( context : Record < PropertyKey , S . XSchema > , schema : S . XSchema ) {
104- super ( context , schema )
82+ constructor ( ) {
10583 this . indices = new Set ( )
10684 this . keys = new Set ( )
10785 }
@@ -119,9 +97,6 @@ export class CheckContext extends BaseContext {
11997 public GetKeys ( ) : Set < string > {
12098 return this . keys
12199 }
122- public Clone ( ) {
123- return new CheckContext ( this . context , this . schema )
124- }
125100 public Merge ( results : CheckContext [ ] ) : true {
126101 for ( const context of results ) {
127102 context . indices . forEach ( value => this . indices . add ( value ) )
@@ -135,8 +110,8 @@ export class CheckContext extends BaseContext {
135110// ------------------------------------------------------------------
136111export type ErrorContextCallback = ( error : TValidationError ) => unknown
137112export class ErrorContext extends CheckContext {
138- constructor ( context : Record < PropertyKey , S . XSchema > , schema : S . XSchema , private readonly callback : ErrorContextCallback ) {
139- super ( context , schema )
113+ constructor ( private readonly callback : ErrorContextCallback ) {
114+ super ( )
140115 }
141116 public AddError ( error : TValidationError ) : false {
142117 this . callback ( error )
@@ -148,8 +123,8 @@ export class ErrorContext extends CheckContext {
148123// ------------------------------------------------------------------
149124export class AccumulatedErrorContext extends ErrorContext {
150125 private readonly errors : TValidationError [ ]
151- constructor ( context : Record < PropertyKey , S . XSchema > , schema : S . XSchema ) {
152- super ( context , schema , error => this . errors . push ( error ) )
126+ constructor ( ) {
127+ super ( error => this . errors . push ( error ) )
153128 this . errors = [ ]
154129 }
155130 public override AddError ( error : TValidationError ) : false {
0 commit comments