Cleans and returns the $value.
If it is invalid, the validator fails.

@param   mixed $value
@param   boolean $silent
@return  mixed
485053
public function check($value, $silent = false)
    {
        try {
            return $this->clean($value);
        } catch (ValidationException $e) {
            return $this->fail($e, $value, $silent);
        }
    }
739517
public function clean($value)
    {
        if ($value === true || $value === false) {
            return $value;
        } elseif (is_array($value)) {
            foreach ($value as $k => $v) {
                $value[$k] = $this->clean($v);
            }
        } else {
            $value = preg_replace('/^\"|\"$/', '', $value);
            $value = stripcslashes($value);
        }

        return $value;
    }
370220
public function validate($value)
    {
        $result = !$this->isRequired;
        if ($this->isRequired()) {
            $result = !empty($value);
        }
        if (is_callable($this->validator)) {
            $result = call_user_func($this->validator, $value);
        }

        return $result;
    }
553387
public function validate($value)
    {
        $return = $this->validateCommon($value, new ValidateResult($value, true));

        if ($return->status === false) {
            return $return;
        }

        return $this->validateNumber($return->value);
    }
851822
private static function toPlainValue($value)
    {
        if (is_string($value)) {
            $value = strip_tags($value);
            $value = html_entity_decode($value, ENT_QUOTES | ENT_XML1, 'UTF-8');
            $value = trim($value);

            return ($value === '') ? null : $value;
        }

        return $value;
    }
468576
private function getNumberValueOrNull($value)
    {
        if (!is_scalar($value) || is_bool($value) || (string) $value === '' || !is_numeric((string) $value)) {
            return null;
        }

        if ($this->isFloat() === true) {
            return is_float($value) ? $value : (float) $value;
        }

        return is_int($value) ? $value : (int) $value;
    }
43304
public static function getMessageForError($value)
    {
        if (self::isValidName($value)) {
            $value = self::getNameValue($value);
        }

        return isset(self::$messages[$value]) ? self::$messages[$value] : null;
    }
300997
public function valid($value = null)
    {
        // si la valeur n'ets pas null, on la set
        if (!is_null($value)) {
            $value = (is_string($value)) ? trim($value) : $value;
            if ($this->hasFilterer()) {
                $value = $this->getFilterer()->filter($value);
            }
            $this->setValue($value);
        }

        $this->getValidator()->valid($this->getValue());

        return $this;
    }
1058188
public static function validate($string, $silent = false)
    {
        @json_decode($string);
        if (json_last_error() != JSON_ERROR_NONE) {
            if ($silent == false) {
                //Throw an Exception for string or array
                throw new \InvalidArgumentException("Invalid JSON String");
            }
            return false;
        }
        return true;
    }
588690
public function validate($value)
    {
        $this->pushResult();
        if ($this->acceptsEmptyValues === false || $this->isEmpty($value) === false) {
            $this->isValid($value);
        }
        return $this->popResult();
    }
759449
public function clean($value)
  {
    // First prune whitespace.
    $cleaner = PruneWhitespaceCleaner::get();
    $value   = $cleaner->clean($value);

    // If the value is empty return immediately,
    if ($value==='' || $value===null || $value===false)
    {
      return null;
    }

    // Split the URL in parts.
    $parts = parse_url($value);
    if (!is_array($parts))
    {
      return $value;
    }

    return Url::unParseUrl($parts, 'http');
  }
704606
public function output($value = null)
    {
        $value = is_null($value) ? $this->value : $value;

        return $this->isRepeatable()
            ? $this->outputRepeatable().$this->getExplanation()
            : $this->outputInput($value).$this->getExplanation();
    }
1084298
protected function _sanitize($value)
    {
        //Tidy is not installed, return the input
        if ($tidy = $this->getTidy($value)) {
            if ($tidy->cleanRepair()) {
                $value = (string) $tidy;
            }
        }

        return $value;
    }
383296
protected function validator($value)
    {
        $value = parent::validator($value);

        if ($this->hasErrors()) {
            return null;
        } elseif ($value == '') {
            if ($this->mandatory) {
                $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['mandatory'], $this->strLabel));
            }
        } elseif (!$this->iconExists($value)) {
            $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['iconNotFound'], $this->strLabel));
        }

        return $value;
    }
1072529
protected function _cleanValue($value, $trim = false)
    {
        $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
        return ($trim) ? trim($value) : $value;
    }
1055481
public function validate($value) {
        // Sadly php bug #67167 makes the following lines necessary
        if(is_null($value)) {
            return new ValidationResult(false, 'Not a valid boolean but NULL', self::ERR_NULL);
        }
        if(is_object($value)) {
            return new ValidationResult(false, 'Not a valid boolean but an object', self::ERR_OBJECT);
        }
        
        if(filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)===null) {
            return new ValidationResult(false, 'Not a valid boolean', self::ERR_NOBOOLEAN);
        }        
        return new ValidationResult(true);
    }
53025
public function sanitize($value)
    {
        $result = null;

        // Try to create a transliterator and ensure it actually works
        if (class_exists('Transliterator'))
        {
            try
            {
                // This returns NULL on failure
                $transliterator = Transliterator::create('Any-Latin; [^a-ÿ] Latin-ASCII; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove;');

                // transliterate method returns FALSE on failure
                if ($transliterator && ($sanitized = $transliterator->transliterate($value)) !== false) {
                    $result = $sanitized;
                }
            } catch (Exception $e) {}
        }

        if ($result === null)
        {
            $result = htmlentities(utf8_decode($value), ENT_SUBSTITUTE);
            $result = preg_replace(
                array('/&szlig;/','/&(..)lig;/', '/&([aouAOU])uml;/','/&(.)[^;]*;/'),
                array('ss',"$1","$1".'e',"$1"),
                $result);
        }

        return $result;
    }