@@ -8,14 +8,14 @@ no warnings qw/experimental::signatures/;
88use YAML::XS qw/ LoadFile/ ;
99
1010require Exporter;
11- use base qw( Exporter) ;
11+ use base qw/ Exporter/ ;
1212our @EXPORT_OK = qw/ isValidSetting mergeCourseSettings isInteger isTimeString isTimeDuration isDecimal/ ;
1313
14- use Exception::Class qw(
14+ use Exception::Class qw/
1515 DB::Exception::UndefinedCourseField
1616 DB::Exception::InvalidCourseField
1717 DB::Exception::InvalidCourseFieldType
18- ) ;
18+ / ;
1919
2020use DateTime::TimeZone;
2121use JSON::PP;
@@ -80,35 +80,34 @@ sub isValidSetting ($setting, $value = undef) {
8080 if ($setting -> {type } eq ' text' ) {
8181 # any val is valid.
8282 } elsif ($setting -> {type } eq ' boolean' ) {
83- my $is_bool = JSON::PP::is_bool($val );
8483 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 ) ;
8786 } elsif ($setting -> {type } eq ' list' ) {
8887 validateList($setting , $val );
8988 } elsif ($setting -> {type } eq ' multilist' ) {
9089 validateMultilist($setting , $val );
9190 } 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" )
9493 unless isTimeString($val );
9594 } elsif ($setting -> {type } eq ' int' ) {
9695 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." )
9897 unless isInteger($val );
9998 } elsif ($setting -> {type } eq ' decimal' ) {
10099 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. " )
102101 unless isDecimal($val );
103102 } elsif ($setting -> {type } eq ' time_duration' ) {
104103 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. " )
106105 unless $val =~ / ^\d +$ / ;
107106 } elsif ($setting -> {type } eq ' timezone' ) {
108107 # try to make a new timeZone. If the name isn't valid an 'Invalid offset:' will be thrown.
109108 DateTime::TimeZone-> new(name => $val );
110109 } 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. " );
112111 }
113112 return 1;
114113}
0 commit comments