You are here

public static function PriceModified::validateDefaultValue in Price 8

Same name and namespace in other branches
  1. 3.x src/Element/PriceModified.php \Drupal\price\Element\PriceModified::validateDefaultValue()
  2. 3.0.x src/Element/PriceModified.php \Drupal\price\Element\PriceModified::validateDefaultValue()

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 PriceModified::validateDefaultValue()
PriceModified::processElement in src/Element/PriceModified.php
Builds the price_price form element.

File

src/Element/PriceModified.php, line 186

Class

PriceModified
Provides a price form element.

Namespace

Drupal\price\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('currency_code', $default_value) || !array_key_exists('modifier', $default_value)) {
    return FALSE;
  }
  return TRUE;
}