You are here

static function Notifications_Field::validate_value in Notifications 7

Check if the value is valid for this field has a valid value

Was: notifications_field_valid_value($value, $type = NULL)

1 call to Notifications_Field::validate_value()
Notifications_Field::valid_value in ./notifications.field.inc
Check if this is a valid value for this field

File

./notifications.field.inc, line 313
Drupal Notifications Framework - Default class file

Class

Notifications_Field
Base class for Notifications fields

Code

static function validate_value($value, $data_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 ($data_type) {

    // We want aditional field type validation
    switch ($data_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;
  }
}