Demo entry 6354430

test

   

Submitted by anonymous on Apr 06, 2017 at 22:42
Language: PHP. Code size: 480 Bytes.

<?php

use Phalcon\Validation;
use Phalcon\Validation\Validator\PresenceOf;

$validation = new Validation();
$validation->add(
    'description', 
    new PresenceOf(
        [
            'message'    => 'Description is required',
            'allowEmpty' => [null],
        ]
    )
);

$messages = $validation->validate(['description' => null]); // empty messages
$messages = $validation->validate(['description' => '']);   // will return message from validator

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).