# Validation Service

The validation service is again [a multi-handler service](/foundations-module/utilities/handlers-and-services.md) with no [action methods](/foundations-module/actions.md). Its purpose is to standardize validating a value against a given type and a known default before using it in your code. It provides these public methods:

* `validate_value` which is just a central hub for calling the other methods
* `validate_boolean_value` for turning a value into a boolean or returning the default
* `validate_integer_value` for turning a value into an integer or returning the default
* `validate_float_value` for turning a value into a float or returning the default
* `validate_callback_value` for checking whether a value is a valid callback or returning the default
* `validate_supported_value` for checking whether a value is part of a supported list of values or returning the default

As you're probably expecting by now, all of these methods simply pass on the parameters to a given handler. The handler is free to decide what to do with those values -- the only non-negotiable aspect of this all is the return type of the validation operation. A boolean validation must return a boolean value.

There is just one type of handler pre-packaged with the module and that is the so-called [container validation handler](https://github.com/deep-web-solutions/wordpress-framework-utilities/blob/master/src/includes/Validation/Handlers/ContainerValidationHandler.php). Basically this handler expects to be provided with a PSR-11-compatible container that contains exactly two 2 keys: `defaults` and `options`. Both keys should store an array. The former array is used for returning the default values and the latter for checking for supported options (for the supported value validation). The actual type validation is performed using the validation helpers from [the Helpers Module](/helpers-module/motivation.md).

If you need a different logic, you may use your own custom handler that implements the [`ValidationHandlerInterface`](https://github.com/deep-web-solutions/wordpress-framework-utilities/blob/master/src/includes/Validation/ValidationHandlerInterface.php) interface.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://framework.deep-web-solutions.com/utilities-module/validation-service.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
