diff options
Diffstat (limited to 'lib/MDV')
-rw-r--r-- | lib/MDV/Distribconf/MediaCFG.pm | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/MDV/Distribconf/MediaCFG.pm b/lib/MDV/Distribconf/MediaCFG.pm index 46b3dc5..0566f3c 100644 --- a/lib/MDV/Distribconf/MediaCFG.pm +++ b/lib/MDV/Distribconf/MediaCFG.pm @@ -117,7 +117,21 @@ added to the config (urpmi). =cut -$value->{size} = {}; +$value->{size} = { + validation => sub { + my ($v) = @_; + if ($v =~ /^(\d+)(\w)?$/) { + if ($2) { + if (! grep { lc($2) eq $_ } qw(k m g t p)) { + return("wrong unit"); + } + } + return; + } else { + return ("malformed value"); + } + }, +}; =head3 size @@ -125,7 +139,11 @@ The size of the media. The value is suffixed by the unit. =cut -sub valid_param { +# valid_param($media, $var, $val) +# +# Return a list of errors (if any) about having such value in the config + +sub _valid_param { my ($media, $var, $val) = @_[-3..-1]; if (!exists($value->{$var})) { return ("unknow var"); @@ -141,4 +159,14 @@ sub valid_param { return @errors; } +# Retun a hash containing information about $var + +sub _value_info { + my ($var) = $_[-1]; + if (exists($value->{$var})) { + return $value->{$var} + } + return; +} + 1; |