You are here

function backup_migrate_fraction_validate in Backup and Migrate 7.3

Validate fields that require a decimal between 0 and 1.

@todo Better name.

2 string references to 'backup_migrate_fraction_validate'
backup_migrate_ui_advanced_settings_form in ./backup_migrate.advanced_settings.inc
The advanced settings form.
BmTestBasics::testFieldValidators in tests/BmTestBasics.test
Test the custom validators.

File

./backup_migrate.advanced_settings.inc, line 182
Functionality required for the advanced settings form.

Code

function backup_migrate_fraction_validate($element, &$form_state, $form) {
  $value = $element['#value'];
  $test = preg_match('/^(0|1|0?\\.[0-9]+)$/', $value);
  if ($test !== 1) {
    form_error($element, t('%name must be a decimal between 0 and 1.', array(
      '%name' => $element['#title'],
    )));
  }
}