Posted On: May 03, 2024
Phalcon uses an independent module “Phalcon\Validation” for validating users requests. This component can be used to implement validation rules on data objects that do not belong to a model or collection.
The loosely-coupled design of this component allows you to create your own validators along with the ones provided by the framework.
The following example shows basic usage of validations in Phalcon :
<?php use Phalcon\Forms\Element\Text; use Phalcon\Validation\Validator\PresenceOf; use Phalcon\Validation\Validator\StringLength; $name = new Text( "name" ); $name->addValidator( new PresenceOf( [ "message" => "The name is required", ] ) ); $name->addValidator( new StringLength( [ "min" => 10, "messageMinimum" => "The name is too short", ] ) ); $form->add($name);
Never Miss an Articles from us.
Explain Dependency Injection in Phalcon?..
List basic features provided by Phalcon?..