You are here

public static function Dimensions::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 Dimensions::validateDefaultValue()
Dimensions::processElement in src/Element/Dimensions.php
Builds the physical_dimensions form element.

File

src/Element/Dimensions.php, line 164

Class

Dimensions
Provides a dimension form element.

Namespace

Drupal\physical\Element

Code

public static function validateDefaultValue($default_value) {
  if (!is_array($default_value)) {
    return FALSE;
  }
  foreach ([
    'length',
    'width',
    'height',
    'unit',
  ] as $property) {
    if (!array_key_exists($property, $default_value)) {
      return FALSE;
    }
  }
  return TRUE;
}