You are here

public static function Price::validateDefaultValue in Price 8

Same name and namespace in other branches
  1. 3.x src/Element/Price.php \Drupal\price\Element\Price::validateDefaultValue()
  2. 2.0.x src/Element/Price.php \Drupal\price\Element\Price::validateDefaultValue()
  3. 2.x src/Element/Price.php \Drupal\price\Element\Price::validateDefaultValue()
  4. 3.0.x src/Element/Price.php \Drupal\price\Element\Price::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 Price::validateDefaultValue()
Price::processElement in src/Element/Price.php
Builds the price_price form element.

File

src/Element/Price.php, line 168

Class

Price
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)) {
    return FALSE;
  }
  return TRUE;
}