You are here

public static function Fraction::validateDefaultValue in Fraction 2.x

Same name and namespace in other branches
  1. 8 src/Element/Fraction.php \Drupal\fraction\Element\Fraction::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 Fraction::validateDefaultValue()
Fraction::processElement in src/Element/Fraction.php
Builds the fraction form element.

File

src/Element/Fraction.php, line 133

Class

Fraction
Provides a fraction form element.

Namespace

Drupal\fraction\Element

Code

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