Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Feb 24, 2024
1 parent 91de2cb commit 461d824
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Recorders/ValidationErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected function parseSessionValidationErrors(Request $request, BaseResponse $

// TODO test this
return collect($bags)->flatMap(
fn ($bag, $bagName) => collect($bags[0]->keys())->map(fn ($inputName) => "{$bagName}:{$inputName}")
fn ($bag, $bagName) => collect($bag->keys())->map(fn ($inputName) => "{$bagName}:{$inputName}")
);
}

Expand All @@ -118,12 +118,12 @@ protected function parseJsonValidationErrors(Request $request, BaseResponse $res
! is_array($response->original) ||
! array_key_exists('errors', $response->original) ||
! is_array($response->original['errors']) ||
array_is_list($response->original['errors'])
array_is_list($errors = $response->original['errors'])
) {
return null;
}

return collect($response->original['errors'])->keys();
return collect($errors)->keys();
}

/**
Expand All @@ -140,13 +140,19 @@ protected function parseInertiaValidationErrors(Request $request, BaseResponse $
! array_key_exists('props', $response->original) ||
! is_array($response->original['props']) ||
! array_key_exists('errors', $response->original['props']) ||
! $response->original['props']['errors'] instanceof stdClass
! ($errors = $response->original['props']['errors']) instanceof stdClass
) {
return null;
}

// TODO error bags
return collect($response->original['props']['errors'])->keys();
if (is_string(($errors = collect($errors))->first())) {
return $errors->keys();
}

// TODO test this
return $errors->flatMap(
fn ($bag, $bagName) => collect($bag)->keys()->map(fn ($inputName) => "{$bagName}:{$inputName}")
);
}

/**
Expand Down

0 comments on commit 461d824

Please sign in to comment.