You are here

function notifications_field_valid_value in Notifications 6.4

Check if the field has a valid value

2 calls to notifications_field_valid_value()
notifications_field_real_value in includes/object.inc
Convert field value from submission into its real value
notifications_field_validate_submitted in includes/object.inc
Validate submitted field values and set the new ones as valid array of values

File

includes/object.inc, line 344
Notifications object and fields

Code

function notifications_field_valid_value($value, $type = NULL) {

  // A numeric value of zero is possible too, that's why the is_numeric()
  if (!is_numeric($value) && empty($value)) {

    // The field has no value at all, no go
    return FALSE;
  }
  elseif ($type) {

    // We want aditional field type validation
    switch (notifications_field_type($type, 'type')) {
      case 'int':

        // @todo Better integer validation, is_int not working for strings
        return is_numeric($value);
      case 'float':
        return is_numeric($value);
      case 'string':
      default:
        return is_string($value);
    }
  }
  else {
    return TRUE;
  }
}