@@ -8,14 +8,14 @@ no warnings qw/experimental::signatures/;
8
8
use YAML::XS qw/ LoadFile/ ;
9
9
10
10
require Exporter;
11
- use base qw( Exporter) ;
11
+ use base qw/ Exporter/ ;
12
12
our @EXPORT_OK = qw/ isValidSetting mergeCourseSettings isInteger isTimeString isTimeDuration isDecimal/ ;
13
13
14
- use Exception::Class qw(
14
+ use Exception::Class qw/
15
15
DB::Exception::UndefinedCourseField
16
16
DB::Exception::InvalidCourseField
17
17
DB::Exception::InvalidCourseFieldType
18
- ) ;
18
+ / ;
19
19
20
20
use DateTime::TimeZone;
21
21
use JSON::PP;
@@ -80,35 +80,34 @@ sub isValidSetting ($setting, $value = undef) {
80
80
if ($setting -> {type } eq ' text' ) {
81
81
# any val is valid.
82
82
} elsif ($setting -> {type } eq ' boolean' ) {
83
- my $is_bool = JSON::PP::is_bool($val );
84
83
DB::Exception::InvalidCourseFieldType-> throw(
85
- message => qq/ The variable $setting ->{setting_name} has value $val and must be a boolean./ )
86
- unless $ is_bool ;
84
+ message => " The variable $setting ->{setting_name} has value $val and must be a boolean." )
85
+ unless JSON::PP:: is_bool( $val ) ;
87
86
} elsif ($setting -> {type } eq ' list' ) {
88
87
validateList($setting , $val );
89
88
} elsif ($setting -> {type } eq ' multilist' ) {
90
89
validateMultilist($setting , $val );
91
90
} elsif ($setting -> {type } eq ' time' ) {
92
- DB::Exception::InvalidCourseFieldType-> throw(message =>
93
- qq/ The variable $setting ->{setting_name} has value $val and must be a time in the form XX:XX/ )
91
+ DB::Exception::InvalidCourseFieldType-> throw(
92
+ message => " The variable $setting ->{setting_name} has value $val and must be a time in the form XX:XX" )
94
93
unless isTimeString($val );
95
94
} elsif ($setting -> {type } eq ' int' ) {
96
95
DB::Exception::InvalidCourseFieldType-> throw(
97
- message => qq/ The variable $setting ->{setting_name} has value $val and must be an integer./ )
96
+ message => " The variable $setting ->{setting_name} has value $val and must be an integer." )
98
97
unless isInteger($val );
99
98
} elsif ($setting -> {type } eq ' decimal' ) {
100
99
DB::Exception::InvalidCourseFieldType-> throw(
101
- message => qq/ The variable $setting ->{setting_name} has value $val and must be a decimal/ )
100
+ message => " The variable $setting ->{setting_name} has value $val and must be a decimal. " )
102
101
unless isDecimal($val );
103
102
} elsif ($setting -> {type } eq ' time_duration' ) {
104
103
DB::Exception::InvalidCourseFieldType-> throw(
105
- message => qq/ The variable $setting ->{setting_name} has value $val and must be a time duration/ )
104
+ message => " The variable $setting ->{setting_name} has value $val and must be a time duration. " )
106
105
unless $val =~ / ^\d +$ / ;
107
106
} elsif ($setting -> {type } eq ' timezone' ) {
108
107
# try to make a new timeZone. If the name isn't valid an 'Invalid offset:' will be thrown.
109
108
DateTime::TimeZone-> new(name => $val );
110
109
} else {
111
- DB::Exception::InvalidCourseFieldType-> throw(message => qq/ The setting type $setting ->{type} is not valid/ );
110
+ DB::Exception::InvalidCourseFieldType-> throw(message => " The setting type $setting ->{type} is not valid. " );
112
111
}
113
112
return 1;
114
113
}
0 commit comments