1# Call
2
3- `v::call(callable $callback)`
4
5This is a very low level validator. It calls a function, method or closure
6for the input and then validates it. Consider the following variable:
7
8```php
9$url = 'http://www.google.com/search?q=respect.github.com'
10```
11
12To validate every part of this URL we could use the native `parse_url`
13function to break its parts:
14
15```php
16$parts = parse_url($url);
17```
18
19This function returns an array containing `scheme`, `host`, `path` and `query`.
20We can validate them this way:
21
22```php
23v::arrayVal()->key('scheme', v::startsWith('http'))
24        ->key('host',   v::domain())
25        ->key('path',   v::stringType())
26        ->key('query',  v::notEmpty());
27```
28
29Using `v::call()` you can do this in a single chain:
30
31```php
32v::call(
33    'parse_url',
34     v::arrayVal()->key('scheme', v::startsWith('http'))
35        ->key('host',   v::domain())
36        ->key('path',   v::stringType())
37        ->key('query',  v::notEmpty())
38)->validate($url);
39```
40
41It is possible to call methods and closures as the first parameter:
42
43```php
44v::call([$myObj, 'methodName'], v::intVal())->validate($myInput);
45v::call(function($input) {}, v::intVal())->validate($myInput);
46```
47
48***
49See also:
50
51  * [Callback](Callback.md)
52