From ea40b04f0ff65bd56eead8bcaee007db7d39359f Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Tue, 12 Oct 2010 22:14:30 -0700 Subject: Handle git booleans with a more correct constraint. --- usr/src/libpiny/lib/Piny/Config.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'usr') diff --git a/usr/src/libpiny/lib/Piny/Config.pm b/usr/src/libpiny/lib/Piny/Config.pm index 00e4902..a162e2a 100644 --- a/usr/src/libpiny/lib/Piny/Config.pm +++ b/usr/src/libpiny/lib/Piny/Config.pm @@ -7,11 +7,20 @@ use warnings; package Piny::Config; use Moose; +use Moose::Util::TypeConstraints; use MooseX::StrictConstructor; use Carp; use Config::Simple qw( ); +# Types + +subtype 'GitBool' + => as 'Str' + => where { $_ =~ /^(1|0|true|false)$/i } + => message { 'Not correct format for a git-compatible boolean.' } + ; + # Attributes has 'confpath' => @@ -174,7 +183,7 @@ tweakable "piny_ikiwikisrcdir" => "/srv/ikiwiki/", 'Str'; tweakable "piny_ikiwikiurl" => "http://piny.be/", 'Str'; tweakable "piny_ikiwikisecureurl" => "https://secure.piny.be/", 'Str'; tweakable "piny_ikiwikisecurepath" => "/srv/www/secure.piny.be/", 'Str'; -tweakable "receive_denyNonFastforwards" => "true", 'Bool'; +tweakable "receive_denyNonFastforwards" => "true", 'GitBool'; # Moose boilerplate -- cgit v1.2.3