You are here

fapi_filters.inc in Form API Validation 8

File

src/fapi_filters/fapi_filters.inc
View source
<?php

/**
 * Implementation of hook_fapi_validation_filters
 */
function fapi_validation_fapi_validation_filters() {
  return array(
    'numeric' => array(
      'callback' => 'fapi_validation_filter_numeric',
    ),
    'trim' => array(
      'callback' => 'fapi_validation_filter_trim',
    ),
    'uppercase' => array(
      'callback' => 'fapi_validation_filter_uppercase',
    ),
    'lowercase' => array(
      'callback' => 'fapi_validation_filter_lowercase',
    ),
    'strip_tags' => array(
      'callback' => 'fapi_validation_filter_strip_tags',
    ),
    'html_entities' => array(
      'callback' => 'fapi_validation_filter_html_entities',
    ),
  );
}

/**
 * Filters
 */
function fapi_validation_filter_numeric($value) {
  return preg_replace('/[^0-9]+/', '', $value);
}
function fapi_validation_filter_trim($value) {
  return trim($value);
}
function fapi_validation_filter_uppercase($value) {
  return mb_strtoupper($value);
}
function fapi_validation_filter_lowercase($value) {
  return mb_strtolower($value);
}
function fapi_validation_filter_strip_tags($value) {
  return strip_tags($value);
}
function fapi_validation_filter_html_entities($value) {
  return htmlentities(html_entity_decode($value));
}