Skip to content

Commit

Permalink
Fix #12029 : minimum length of custom fields of type numeric is not c…
Browse files Browse the repository at this point in the history
…hecked
  • Loading branch information
rombert committed Dec 7, 2011
1 parent 8fb27ae commit 9c71d4f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/custom_field_api.php
Expand Up @@ -1158,10 +1158,20 @@ function custom_field_validate( $p_field_id, $p_value ) {
break;
case CUSTOM_FIELD_TYPE_NUMERIC:
$t_valid &= ( $t_length == 0 ) || is_numeric( $p_value );

# Check the length of the number
$t_valid &= ( 0 == $t_length_min ) || ( $t_length >= $t_length_min );
$t_valid &= ( 0 == $t_length_max ) || ( $t_length <= $t_length_max );

break;
case CUSTOM_FIELD_TYPE_FLOAT:
# Allow both integer and float numbers
$t_valid &= ( $t_length == 0 ) || is_numeric( $p_value ) || is_float( $p_value );

# Check the length of the number
$t_valid &= ( 0 == $t_length_min ) || ( $t_length >= $t_length_min );
$t_valid &= ( 0 == $t_length_max ) || ( $t_length <= $t_length_max );

break;
case CUSTOM_FIELD_TYPE_DATE:
# gpc_get_cf for date returns the value from strftime
Expand Down

0 comments on commit 9c71d4f

Please sign in to comment.