PHP Class Cviebrock\ImageValidator\ImageValidator

Inheritance: extends Illuminate\Validation\Validator, implements Illuminate\Contracts\Validation\Validator
Mostra file Open project: cviebrock/image-validator Class Usage Examples

Public Methods

Method Description
__construct ( Symfony\Component\Translation\TranslatorInterface $translator, array $data, array $rules, array $messages = [], array $customAttributes = [] ) Creates a new instance of ImageValidator
replaceImageAspect ( string $message, string $attribute, string $rule, array $parameters ) : string Build the error message for validation failures.
replaceImageSize ( string $message, string $attribute, string $rule, array $parameters ) : string Build the error message for validation failures.
validateImageAspect ( $attribute, $value, $parameters ) : boolean Usage: image_aspect:ratio
validateImageSize ( $attribute, $value, $parameters ) : boolean Usage: image_size:width[,height]

Protected Methods

Method Description
checkDimension ( string $rule, integer $dimension ) : array Parse the dimension rule and check if the dimension passes the rule.
getImagePath ( $value )

Method Details

__construct() public method

Creates a new instance of ImageValidator
public __construct ( Symfony\Component\Translation\TranslatorInterface $translator, array $data, array $rules, array $messages = [], array $customAttributes = [] )
$translator Symfony\Component\Translation\TranslatorInterface
$data array
$rules array
$messages array
$customAttributes array

checkDimension() protected method

Parse the dimension rule and check if the dimension passes the rule.
protected checkDimension ( string $rule, integer $dimension ) : array
$rule string
$dimension integer
return array

getImagePath() protected method

protected getImagePath ( $value )

replaceImageAspect() public method

Build the error message for validation failures.
public replaceImageAspect ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

replaceImageSize() public method

Build the error message for validation failures.
public replaceImageSize ( string $message, string $attribute, string $rule, array $parameters ) : string
$message string
$attribute string
$rule string
$parameters array
return string

validateImageAspect() public method

Usage: image_aspect:ratio
public validateImageAspect ( $attribute, $value, $parameters ) : boolean
$attribute string
$value string|array
$parameters array
return boolean

validateImageSize() public method

Usage: image_size:width[,height]
public validateImageSize ( $attribute, $value, $parameters ) : boolean
$attribute string
$value string|array
$parameters array
return boolean