VNC-155 ConfigKey can have both type and validator

Type can check whether value is boolean or int, and validator can check
whether another configuration key is defined, for example.
This commit is contained in:
Dmitry Maksyoma 2025-05-14 21:30:58 +12:00
parent f12264c5ad
commit 0924817a76
No known key found for this signature in database

View File

@ -32,13 +32,6 @@ sub validate {
return if $self->isValueBlank(); return if $self->isValueBlank();
if ($self->{validator}) {
$self->resolveValidatorFromFunction() if (ref $self->{validator} eq "CODE");
$self->{validator}->validate($self);
return;
}
switch($self->{type}) { switch($self->{type}) {
case INT { case INT {
$self->validateInt(); $self->validateInt();
@ -47,6 +40,13 @@ sub validate {
$self->validateBoolean(); $self->validateBoolean();
} }
} }
if ($self->{validator}) {
$self->resolveValidatorFromFunction() if (ref $self->{validator} eq "CODE");
$self->{validator}->validate($self);
return;
}
} }
sub resolveValidatorFromFunction { sub resolveValidatorFromFunction {