Skip to content

Commit

Permalink
FIX: base parser validation & text-field
Browse files Browse the repository at this point in the history
  • Loading branch information
girafffee committed Aug 9, 2023
1 parent 5f8cbfe commit ab57541
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/block-parsers/fields/text-field-parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function check_response() {

$type = $this->settings['field_type'] ?? 'text';

if ( $this->is_collected_error( 'empty_field' ) ) {
if ( empty( $this->value ) ) {
return;
}

Expand Down
16 changes: 14 additions & 2 deletions modules/block-parsers/parser-context.php
Original file line number Diff line number Diff line change
Expand Up @@ -683,14 +683,26 @@ public function collect_error( $name, $error_name ) {
public function iterate_errors(): \Generator {
/** @var Field_Data_Parser $parser */
foreach ( $this->iterate_parsers() as $parser ) {
yield $parser->get_name() => $parser->get_errors();
$errors = $parser->get_errors();

if ( ! $errors ) {
continue;
}

yield $parser->get_name() => $errors;
}
}

public function iterate_errors_list(): \Generator {
/** @var Field_Data_Parser $parser */
foreach ( $this->iterate_parsers_list() as $name => $parser ) {
yield $name => $parser->get_errors();
$errors = $parser->get_errors();

if ( ! $errors ) {
continue;
}

yield $name => $errors;
}
}

Expand Down

0 comments on commit ab57541

Please sign in to comment.