summaryrefslogtreecommitdiffstats
path: root/lib/MDV/Distribconf/MediaCFG.pm
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mandriva.org>2006-08-18 14:09:44 +0000
committerOlivier Thauvin <nanardon@mandriva.org>2006-08-18 14:09:44 +0000
commit50bf20203670b3b3a1fd050c588231761f588c5b (patch)
treed0d8af8038b1acf6d78e7dde52b626d18378847b /lib/MDV/Distribconf/MediaCFG.pm
parent43f19b38993c3f57cebaff4cc10425900f7d5246 (diff)
downloadperl-MDV-Distribconf-50bf20203670b3b3a1fd050c588231761f588c5b.tar
perl-MDV-Distribconf-50bf20203670b3b3a1fd050c588231761f588c5b.tar.gz
perl-MDV-Distribconf-50bf20203670b3b3a1fd050c588231761f588c5b.tar.bz2
perl-MDV-Distribconf-50bf20203670b3b3a1fd050c588231761f588c5b.tar.xz
perl-MDV-Distribconf-50bf20203670b3b3a1fd050c588231761f588c5b.zip
- more test, provide basic functions
Diffstat (limited to 'lib/MDV/Distribconf/MediaCFG.pm')
-rw-r--r--lib/MDV/Distribconf/MediaCFG.pm32
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;