Skip to content

Commit

Permalink
use dependency injection to make recursive type validator testable
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieTap committed Jan 15, 2025
1 parent 4f0dda3 commit bd5f238
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ internal fun RecursiveTypeValidator(
RecursiveTypeValidator(
context = context,
type = type,
definedTypeRoller = ::DefinedTypeRoller,
subTypeValidator = ::SubTypeValidator,
recursiveTypeCopier = ::RecursiveTypeDeepCopier,
)

internal inline fun RecursiveTypeValidator(
context: ValidationContext,
type: RecursiveType,
crossinline definedTypeRoller: DefinedTypeRoller,
crossinline subTypeValidator: Validator<SubType>,
crossinline recursiveTypeCopier: DeepCopier<RecursiveType>,
): Result<Unit, ModuleValidatorError> = binding {
Expand All @@ -34,7 +36,7 @@ internal inline fun RecursiveTypeValidator(
// to be in syntax state

val copy = recursiveTypeCopier(type)
val definedType = DefinedTypeRoller(context.types.size, copy)
val definedType = definedTypeRoller(context.types.size, copy)
context.types += definedType

type.subTypes.forEach { subType ->
Expand Down

0 comments on commit bd5f238

Please sign in to comment.