PHP Classes

File: src/Validator/FloatValidator.php

Recommend this page to a friend!
  Classes of Derek McLean   HTML Forms   src/Validator/FloatValidator.php   Download  
File: src/Validator/FloatValidator.php
Role: Class source
Content type: text/plain
Description: Class source
Class: HTML Forms
Generate and validate submitted HTML forms
Author: By
Last change:
Date: 6 years ago
Size: 587 bytes
 

Contents

Class file image Download
<?php
/**
 * User: delboy1978uk
 * Date: 26/12/2016
 * Time: 14:59
 */

namespace Del\Form\Validator;

use
Exception;

class
FloatValidator implements ValidatorInterface
{
   
/**
     * @param mixed $value
     * @return bool
     * @throws Exception If validation of $value is impossible
     */
   
public function isValid($value)
    {
        if (!
is_numeric($value)) {
            return
false;
        }
        return
is_float((float) $value);
    }

   
/**
     * @return array
     */
   
public function getMessages()
    {
        return [
'Value is not a float.'];
    }

}