---
title: "Abstract class **Phalcon\\Mvc\\Model\\Validator**"
version: "3.4"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.phalcon.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Abstract class **Phalcon\Mvc\Model\Validator**

*implements* [Phalcon\Mvc\Model\ValidatorInterface](/3.4/api/phalcon_mvc_model_validator/)

<a href="https://github.com/phalcon/cphalcon/tree/v3.4.0/phalcon/mvc/model/validator.zep" class="btn btn-default btn-sm">Source on GitHub</a>

This is a base class for Phalcon\Mvc\Model validators

This class is only for backward compatibility reasons to use with Phalcon\Mvc\Collection.
Otherwise please use the validators provided by Phalcon\Validation.

## Methods
public  **__construct** (*array* $options)

Phalcon\Mvc\Model\Validator constructor

protected  **appendMessage** (*string* $message, [*string* | *array* $field], [*string* $type])

Appends a message to the validator

public  **getMessages** ()

Returns messages generated by the validator

public *array* **getOptions** ()

Returns all the options from the validator

public  **getOption** (*mixed* $option, [*mixed* $defaultValue])

Returns an option

public  **isSetOption** (*mixed* $option)

Check whether an option has been defined in the validator options

abstract public  **validate** ([Phalcon\Mvc\EntityInterface](/3.4/api/phalcon_mvc_entityinterface/) $record) inherited from [Phalcon\Mvc\Model\ValidatorInterface](/3.4/api/phalcon_mvc_model_validator/)

...

<hr />

# Class **Phalcon\Mvc\Model\Validator\Email**

*extends* abstract class [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

*implements* [Phalcon\Mvc\Model\ValidatorInterface](/3.4/api/phalcon_mvc_model_validator/)

<a href="https://github.com/phalcon/cphalcon/tree/v3.4.0/phalcon/mvc/model/validator/email.zep" class="btn btn-default btn-sm">Source on GitHub</a>

Allows to validate if email fields has correct values

This validator is only for use with Phalcon\Mvc\Collection. If you are using
Phalcon\Mvc\Model, please use the validators provided by Phalcon\Validation.

```php
<?php

use Phalcon\Mvc\Model\Validator\Email as EmailValidator;

class Subscriptors extends \Phalcon\Mvc\Collection
{
public function validation()
{
    $this->validate(
        new EmailValidator(
            [
                "field" => "electronic_mail",
            ]
        )
    );

    if ($this->validationHasFailed() === true) {
        return false;
    }
}
}

```

## Methods
public  **validate** ([Phalcon\Mvc\EntityInterface](/3.4/api/phalcon_mvc_entityinterface/) $record)

Executes the validator

public  **__construct** (*array* $options) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Phalcon\Mvc\Model\Validator constructor

protected  **appendMessage** (*string* $message, [*string* | *array* $field], [*string* $type]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Appends a message to the validator

public  **getMessages** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns messages generated by the validator

public *array* **getOptions** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns all the options from the validator

public  **getOption** (*mixed* $option, [*mixed* $defaultValue]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns an option

public  **isSetOption** (*mixed* $option) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Check whether an option has been defined in the validator options

<hr />

# Class **Phalcon\Mvc\Model\Validator\Exclusionin**

*extends* abstract class [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

*implements* [Phalcon\Mvc\Model\ValidatorInterface](/3.4/api/phalcon_mvc_model_validator/)

<a href="https://github.com/phalcon/cphalcon/tree/v3.4.0/phalcon/mvc/model/validator/exclusionin.zep" class="btn btn-default btn-sm">Source on GitHub</a>

Phalcon\Mvc\Model\Validator\ExclusionIn

Check if a value is not included into a list of values

This validator is only for use with Phalcon\Mvc\Collection. If you are using
Phalcon\Mvc\Model, please use the validators provided by Phalcon\Validation.

```php
<?php

use Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionInValidator;

class Subscriptors extends \Phalcon\Mvc\Collection
{
public function validation()
{
    $this->validate(
        new ExclusionInValidator(
            [
                "field"  => "status",
                "domain" => ["A", "I"],
            ]
        )
    );

    if ($this->validationHasFailed() === true) {
        return false;
    }
}
}

```

## Methods
public  **validate** ([Phalcon\Mvc\EntityInterface](/3.4/api/phalcon_mvc_entityinterface/) $record)

Executes the validator

public  **__construct** (*array* $options) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Phalcon\Mvc\Model\Validator constructor

protected  **appendMessage** (*string* $message, [*string* | *array* $field], [*string* $type]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Appends a message to the validator

public  **getMessages** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns messages generated by the validator

public *array* **getOptions** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns all the options from the validator

public  **getOption** (*mixed* $option, [*mixed* $defaultValue]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns an option

public  **isSetOption** (*mixed* $option) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Check whether an option has been defined in the validator options

<hr />

# Class **Phalcon\Mvc\Model\Validator\Inclusionin**

*extends* abstract class [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

*implements* [Phalcon\Mvc\Model\ValidatorInterface](/3.4/api/phalcon_mvc_model_validator/)

<a href="https://github.com/phalcon/cphalcon/tree/v3.4.0/phalcon/mvc/model/validator/inclusionin.zep" class="btn btn-default btn-sm">Source on GitHub</a>

Phalcon\Mvc\Model\Validator\InclusionIn

Check if a value is included into a list of values

This validator is only for use with Phalcon\Mvc\Collection. If you are using
Phalcon\Mvc\Model, please use the validators provided by Phalcon\Validation.

```php
<?php

use Phalcon\Mvc\Model\Validator\InclusionIn as InclusionInValidator;

class Subscriptors extends \Phalcon\Mvc\Collection
{
public function validation()
{
    $this->validate(
        new InclusionInValidator(
            [
                "field"  => "status",
                "domain" => ["A", "I"],
            ]
        )
    );

    if ($this->validationHasFailed() === true) {
        return false;
    }
}
}

```

## Methods
public  **validate** ([Phalcon\Mvc\EntityInterface](/3.4/api/phalcon_mvc_entityinterface/) $record)

Executes validator

public  **__construct** (*array* $options) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Phalcon\Mvc\Model\Validator constructor

protected  **appendMessage** (*string* $message, [*string* | *array* $field], [*string* $type]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Appends a message to the validator

public  **getMessages** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns messages generated by the validator

public *array* **getOptions** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns all the options from the validator

public  **getOption** (*mixed* $option, [*mixed* $defaultValue]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns an option

public  **isSetOption** (*mixed* $option) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Check whether an option has been defined in the validator options

<hr />

# Class **Phalcon\Mvc\Model\Validator\Ip**

*extends* abstract class [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

*implements* [Phalcon\Mvc\Model\ValidatorInterface](/3.4/api/phalcon_mvc_model_validator/)

<a href="https://github.com/phalcon/cphalcon/tree/v3.4.0/phalcon/mvc/model/validator/ip.zep" class="btn btn-default btn-sm">Source on GitHub</a>

Phalcon\Mvc\Model\Validator\IP

Validates that a value is ipv4 address in valid range

This validator is only for use with Phalcon\Mvc\Collection. If you are using
Phalcon\Mvc\Model, please use the validators provided by Phalcon\Validation.

```php
<?php

use Phalcon\Mvc\Model\Validator\Ip;

class Data extends \Phalcon\Mvc\Collection
{
public function validation()
{
    // Any pubic IP
    $this->validate(
        new IP(
            [
                "field"         => "server_ip",
                "version"       => IP::VERSION_4 | IP::VERSION_6, // v6 and v4. The same if not specified
                "allowReserved" => false,   // False if not specified. Ignored for v6
                "allowPrivate"  => false,   // False if not specified
                "message"       => "IP address has to be correct",
            ]
        )
    );

    // Any public v4 address
    $this->validate(
        new IP(
            [
                "field"   => "ip_4",
                "version" => IP::VERSION_4,
                "message" => "IP address has to be correct",
            ]
        )
    );

    // Any v6 address
    $this->validate(
        new IP(
            [
                "field"        => "ip6",
                "version"      => IP::VERSION_6,
                "allowPrivate" => true,
                "message"      => "IP address has to be correct",
            ]
        )
    );

    if ($this->validationHasFailed() === true) {
        return false;
    }
}
}

```

## Constants
*integer* **VERSION_4**

*integer* **VERSION_6**

## Methods
public  **validate** ([Phalcon\Mvc\EntityInterface](/3.4/api/phalcon_mvc_entityinterface/) $record)

Executes the validator

public  **__construct** (*array* $options) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Phalcon\Mvc\Model\Validator constructor

protected  **appendMessage** (*string* $message, [*string* | *array* $field], [*string* $type]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Appends a message to the validator

public  **getMessages** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns messages generated by the validator

public *array* **getOptions** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns all the options from the validator

public  **getOption** (*mixed* $option, [*mixed* $defaultValue]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns an option

public  **isSetOption** (*mixed* $option) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Check whether an option has been defined in the validator options

<hr />

# Class **Phalcon\Mvc\Model\Validator\Numericality**

*extends* abstract class [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

*implements* [Phalcon\Mvc\Model\ValidatorInterface](/3.4/api/phalcon_mvc_model_validator/)

<a href="https://github.com/phalcon/cphalcon/tree/v3.4.0/phalcon/mvc/model/validator/numericality.zep" class="btn btn-default btn-sm">Source on GitHub</a>

Allows to validate if a field has a valid numeric format

This validator is only for use with Phalcon\Mvc\Collection. If you are using
Phalcon\Mvc\Model, please use the validators provided by Phalcon\Validation.

```php
<?php

use Phalcon\Mvc\Model\Validator\Numericality as NumericalityValidator;

class Products extends \Phalcon\Mvc\Collection
{
public function validation()
{
    $this->validate(
        new NumericalityValidator(
            [
                "field" => "price",
            ]
        )
    );

    if ($this->validationHasFailed() === true) {
        return false;
    }
}
}

```

## Methods
public  **validate** ([Phalcon\Mvc\EntityInterface](/3.4/api/phalcon_mvc_entityinterface/) $record)

Executes the validator

public  **__construct** (*array* $options) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Phalcon\Mvc\Model\Validator constructor

protected  **appendMessage** (*string* $message, [*string* | *array* $field], [*string* $type]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Appends a message to the validator

public  **getMessages** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns messages generated by the validator

public *array* **getOptions** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns all the options from the validator

public  **getOption** (*mixed* $option, [*mixed* $defaultValue]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns an option

public  **isSetOption** (*mixed* $option) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Check whether an option has been defined in the validator options

<hr />

# Class **Phalcon\Mvc\Model\Validator\PresenceOf**

*extends* abstract class [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

*implements* [Phalcon\Mvc\Model\ValidatorInterface](/3.4/api/phalcon_mvc_model_validator/)

<a href="https://github.com/phalcon/cphalcon/tree/v3.4.0/phalcon/mvc/model/validator/presenceof.zep" class="btn btn-default btn-sm">Source on GitHub</a>

Allows to validate if a filed have a value different of null and empty string ("")

This validator is only for use with Phalcon\Mvc\Collection. If you are using
Phalcon\Mvc\Model, please use the validators provided by Phalcon\Validation.

```php
<?php

use Phalcon\Mvc\Model\Validator\PresenceOf;

class Subscriptors extends \Phalcon\Mvc\Collection
{
public function validation()
{
    $this->validate(
        new PresenceOf(
            [
                "field"   => "name",
                "message" => "The name is required",
            ]
        )
    );

    if ($this->validationHasFailed() === true) {
        return false;
    }
}
}

```

## Methods
public  **validate** ([Phalcon\Mvc\EntityInterface](/3.4/api/phalcon_mvc_entityinterface/) $record)

Executes the validator

public  **__construct** (*array* $options) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Phalcon\Mvc\Model\Validator constructor

protected  **appendMessage** (*string* $message, [*string* | *array* $field], [*string* $type]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Appends a message to the validator

public  **getMessages** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns messages generated by the validator

public *array* **getOptions** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns all the options from the validator

public  **getOption** (*mixed* $option, [*mixed* $defaultValue]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns an option

public  **isSetOption** (*mixed* $option) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Check whether an option has been defined in the validator options

<hr />

# Class **Phalcon\Mvc\Model\Validator\Regex**

*extends* abstract class [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

*implements* [Phalcon\Mvc\Model\ValidatorInterface](/3.4/api/phalcon_mvc_model_validator/)

<a href="https://github.com/phalcon/cphalcon/tree/v3.4.0/phalcon/mvc/model/validator/regex.zep" class="btn btn-default btn-sm">Source on GitHub</a>

Allows validate if the value of a field matches a regular expression

This validator is only for use with Phalcon\Mvc\Collection. If you are using
Phalcon\Mvc\Model, please use the validators provided by Phalcon\Validation.

```php
<?php

use Phalcon\Mvc\Model\Validator\Regex as RegexValidator;

class Subscriptors extends \Phalcon\Mvc\Collection
{
public function validation()
{
    $this->validate(
        new RegexValidator(
            [
                "field"   => "created_at",
                "pattern" => "/^[0-9]{4}[-\/](0[1-9]|1[12])[-\/](0[1-9]|[12][0-9]|3[01])/",
            ]
        )
    );

    if ($this->validationHasFailed() == true) {
        return false;
    }
}
}

```

## Methods
public  **validate** ([Phalcon\Mvc\EntityInterface](/3.4/api/phalcon_mvc_entityinterface/) $record)

Executes the validator

public  **__construct** (*array* $options) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Phalcon\Mvc\Model\Validator constructor

protected  **appendMessage** (*string* $message, [*string* | *array* $field], [*string* $type]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Appends a message to the validator

public  **getMessages** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns messages generated by the validator

public *array* **getOptions** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns all the options from the validator

public  **getOption** (*mixed* $option, [*mixed* $defaultValue]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns an option

public  **isSetOption** (*mixed* $option) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Check whether an option has been defined in the validator options

<hr />

# Class **Phalcon\Mvc\Model\Validator\StringLength**

*extends* abstract class [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

*implements* [Phalcon\Mvc\Model\ValidatorInterface](/3.4/api/phalcon_mvc_model_validator/)

<a href="https://github.com/phalcon/cphalcon/tree/v3.4.0/phalcon/mvc/model/validator/stringlength.zep" class="btn btn-default btn-sm">Source on GitHub</a>

Simply validates specified string length constraints

This validator is only for use with Phalcon\Mvc\Collection. If you are using
Phalcon\Mvc\Model, please use the validators provided by Phalcon\Validation.

```php
<?php

use Phalcon\Mvc\Model\Validator\StringLength as StringLengthValidator;

class Subscriptors extends \Phalcon\Mvc\Collection
{
public function validation()
{
    $this->validate(
        new StringLengthValidator(
            [
                "field"          => "name_last",
                "max"            => 50,
                "min"            => 2,
                "messageMaximum" => "We don't like really long names",
                "messageMinimum" => "We want more than just their initials",
            ]
        )
    );

    if ($this->validationHasFailed() === true) {
        return false;
    }
}
}

```

## Methods
public  **validate** ([Phalcon\Mvc\EntityInterface](/3.4/api/phalcon_mvc_entityinterface/) $record)

Executes the validator

public  **__construct** (*array* $options) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Phalcon\Mvc\Model\Validator constructor

protected  **appendMessage** (*string* $message, [*string* | *array* $field], [*string* $type]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Appends a message to the validator

public  **getMessages** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns messages generated by the validator

public *array* **getOptions** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns all the options from the validator

public  **getOption** (*mixed* $option, [*mixed* $defaultValue]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns an option

public  **isSetOption** (*mixed* $option) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Check whether an option has been defined in the validator options

<hr />

# Class **Phalcon\Mvc\Model\Validator\Uniqueness**

*extends* abstract class [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

*implements* [Phalcon\Mvc\Model\ValidatorInterface](/3.4/api/phalcon_mvc_model_validator/)

<a href="https://github.com/phalcon/cphalcon/tree/v3.4.0/phalcon/mvc/model/validator/uniqueness.zep" class="btn btn-default btn-sm">Source on GitHub</a>

Validates that a field or a combination of a set of fields are not
present more than once in the existing records of the related table

This validator is only for use with Phalcon\Mvc\Collection. If you are using
Phalcon\Mvc\Model, please use the validators provided by Phalcon\Validation.

```php
<?php

use Phalcon\Mvc\Collection;
use Phalcon\Mvc\Model\Validator\Uniqueness;

class Subscriptors extends Collection
{
public function validation()
{
    $this->validate(
        new Uniqueness(
            [
                "field"   => "email",
                "message" => "Value of field 'email' is already present in another record",
            ]
        )
    );

    if ($this->validationHasFailed() === true) {
        return false;
    }
}
}

```

## Methods
public  **validate** ([Phalcon\Mvc\EntityInterface](/3.4/api/phalcon_mvc_entityinterface/) $record)

Executes the validator

public  **__construct** (*array* $options) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Phalcon\Mvc\Model\Validator constructor

protected  **appendMessage** (*string* $message, [*string* | *array* $field], [*string* $type]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Appends a message to the validator

public  **getMessages** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns messages generated by the validator

public *array* **getOptions** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns all the options from the validator

public  **getOption** (*mixed* $option, [*mixed* $defaultValue]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns an option

public  **isSetOption** (*mixed* $option) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Check whether an option has been defined in the validator options

<hr />

# Class **Phalcon\Mvc\Model\Validator\Url**

*extends* abstract class [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

*implements* [Phalcon\Mvc\Model\ValidatorInterface](/3.4/api/phalcon_mvc_model_validator/)

<a href="https://github.com/phalcon/cphalcon/tree/v3.4.0/phalcon/mvc/model/validator/url.zep" class="btn btn-default btn-sm">Source on GitHub</a>

Allows to validate if a field has a url format

This validator is only for use with Phalcon\Mvc\Collection. If you are using
Phalcon\Mvc\Model, please use the validators provided by Phalcon\Validation.

```php
<?php

use Phalcon\Mvc\Model\Validator\Url as UrlValidator;

class Posts extends \Phalcon\Mvc\Collection
{
public function validation()
{
    $this->validate(
        new UrlValidator(
            [
                "field" => "source_url",
            ]
        )
    );

    if ($this->validationHasFailed() === true) {
        return false;
    }
}
}

```

## Methods
public  **validate** ([Phalcon\Mvc\EntityInterface](/3.4/api/phalcon_mvc_entityinterface/) $record)

Executes the validator

public  **__construct** (*array* $options) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Phalcon\Mvc\Model\Validator constructor

protected  **appendMessage** (*string* $message, [*string* | *array* $field], [*string* $type]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Appends a message to the validator

public  **getMessages** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns messages generated by the validator

public *array* **getOptions** () inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns all the options from the validator

public  **getOption** (*mixed* $option, [*mixed* $defaultValue]) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Returns an option

public  **isSetOption** (*mixed* $option) inherited from [Phalcon\Mvc\Model\Validator](/3.4/api/phalcon_mvc_model_validator/)

Check whether an option has been defined in the validator options

<hr />

# Interface **Phalcon\Mvc\Model\ValidatorInterface**

<a href="https://github.com/phalcon/cphalcon/tree/v3.4.0/phalcon/mvc/model/validatorinterface.zep" class="btn btn-default btn-sm">Source on GitHub</a>

## Methods
abstract public  **getMessages** ()

...

abstract public  **validate** ([Phalcon\Mvc\EntityInterface](/3.4/api/phalcon_mvc_entityinterface/) $record)

...

Source: https://docs.phalcon.io/3.4/api/phalcon_mvc_model_validator/index.mdx
