# first check delimiters
if ( my $regex = $self->{delimiters_regex} ) {
- my $template = '';
-
foreach my $v (@{ $rec->{$f} }) {
warn "## v = ", dump( $v );
my $l = _pack_subfields_hash( $v, 1 );
warn "## $l [$regex]\n";
+ my $template = '';
$l =~ s/$regex/$template.=$1/eg && warn "## new: $l\n";
warn "## template: $template\n";
- $self->{_delimiters_templates}->{$f}->{$template}++;
+ $self->{_delimiters_templates}->{$f}->{$template}++ if ( $template );
}
}
ok(my $v = new WebPAC::Validate(
path => "$abs_path/data/validate_test",
- delimiters => [ ' : ', ' ; ', ' / ', ' \. ' ],
+ delimiters => [ ' : ', ' ; ', ' / ', ' \. ', ' = ' ],
debug => $debug,
), "new");
}
test_v({
- '900' => [ { 'a' => 'a : aa = aaa : a ; a', 'b' => 'b ; b ; b ; b ; a : / z . z . ' }, { 'c' => 'a : b ; c / d' } ]
+ '900' => [
+ { 'a' => 'a : aa = aaa : a ; a', 'b' => 'b ; b ; b ; b ; a : / z . z . ' },
+ { 'a' => 'a : a : a', 'c' => [ 'a : b ; c', 'a : b ; c / d' ] },
+ { 'a' => 'a : b / c' },
+ { 'a' => 'a : b / c' },
+ ]
});
diag dump($v->{_delimiters_templates});
is_deeply( $v->{_delimiters_templates}, {
900 => {
- "^a : : ; ^b ; ; ; ; : . . " => 1,
- "^a : : ; ^b ; ; ; ; : . . ^c : ; / " => 1,
+ "^a : / " => 2,
+ "^a : : ^c : ; ^c : ; / " => 1,
+ "^a : = : ; ^b ; ; ; ; : . . " => 1,
},
}, 'just subfields and delimiters');