Download the PHP package hsnfirdaus/class-validator without Composer
On this page you can find all versions of the php package hsnfirdaus/class-validator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hsnfirdaus/class-validator
More information about hsnfirdaus/class-validator
Files in hsnfirdaus/class-validator
Package class-validator
Short Description Class Validator using php attribute
License MIT
Informations about the package class-validator
Class Validator (DEPRECATED)
PHP Class Validator using php 8.0 attributes.
[!CAUTION] This package no longer maintained, use symfony/validator instead.
Installation
Using Composer:
Usage
Example Usage:
Then call validate method, it will throw exception if found an error. Currently this package only support property attribute.
Available Attributes
Available attributes (see src/Attribute folder):
IsEmail()
: Email validation (using phpfilter_var
function).IsEnum(enum: ExampleEnum::class)
: Enum validation from string value.IsInteger()
: Integer validation (using phpis_int
function).IsNotEmpty()
: Validate trimmed value is not empty string or null.IsNumeric(length?: number, minLength?: number, maxLength?: number)
: Validate numeric string (using phpis_numeric
function).IsOptional()
: Attribute to mark the property is optional, allow to be not defined.IsString(length?: number, minLength?: number, maxLength?: number)
: Validate string length.Name(name: string)
: Set error message field name (optional, default will be the property name).ValidateArrayClass(type: string)
: Nested validate array of class.ValidateClass()
: Nested validate class.
Error Message
Currently only English and Indonesian error message will thrown (see locale). Default will be English.
To change locale you can use and setLang
method in your root or boot project:
Or, you can use your own locale with setLangDir
method. For example, create your locale file in __DIR__.'/locale/kr.php
, then you can use: