# Float

`Zend_Validate_Float` allows you to validate if a given value contains a floating-point value. This validator validates also localized input.

## Supported options for Zend_Validate_Float

The following options are supported for `Zend_Validate_Float`:

- locale: Sets the locale which will be used to validate localized float values.

## Simple float validation

The simplest way to validate a float is by using the system settings. When no option is used, the environment locale is used for validation:

    $validator = new Zend_Validate_Float();

    $validator->isValid(1234.5);   // returns true
    $validator->isValid('10a01'); // returns false
    $validator->isValid('1,234.5'); // returns true

In the above example we expected that our environment is set to "en" as locale.

## Localized float validation

Often it's useful to be able to validate also localized values. Float values are often written different in other countries. For example using english you will write "1.5". In german you may write "1,5" and in other languages you may use grouping.

`Zend_Validate_Float` is able to validate such notations. But it is limited to the locale you set. See the following code:

    $validator = new Zend_Validate_Float(array('locale' => 'de'));

    $validator->isValid(1234.5); // returns true
    $validator->isValid("1 234,5"); // returns false
    $validator->isValid("1.234"); // returns true

As you can see, by using a locale, your input is validated localized. Using a different notation you get a `FALSE` when the locale forces a different notation.

The locale can also be set afterwards by using `setLocale()` and retrieved by using `getLocale()`.