You are here

public static function Measurement::validateDefaultValue in Physical Fields 8

Validates the default value.

Parameters

mixed $default_value: The default value.

Return value

bool TRUE if the default value is valid, FALSE otherwise.

1 call to Measurement::validateDefaultValue()
Measurement::processElement in src/Element/Measurement.php
Builds the physical_measurement form element.

File

src/Element/Measurement.php, line 155

Class

Measurement
Provides a measurement form element.

Namespace

Drupal\physical\Element

Code

public static function validateDefaultValue($default_value) {
  if (!is_array($default_value)) {
    return FALSE;
  }
  if (!array_key_exists('number', $default_value) || !array_key_exists('unit', $default_value)) {
    return FALSE;
  }
  return TRUE;
}