| 1 | package Strehler::FormFu::Validator::FilenameTooLong; | ||
| 2 | 1 | $Strehler::FormFu::Validator::FilenameTooLong::VERSION = '1.6.8'; | |
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | ▶ | use base 'HTML::FormFu::Validator'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 1 | ▶ | sub validate_value { |
|
Subroutine
validate_value: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 10 | 1 | my ( $self, $value ) = @_; | |
| 11 | 1 | return length $value < 50; | |
| 12 | } | ||
| 13 | |||
| 14 | =encoding utf8 | ||
| 15 | |||
| 16 | =head1 NAME | ||
| 17 | |||
| 18 | Strehler::FormFu::Validator::FilenameTooLong - FormFu Validator for File field in image form. | ||
| 19 | |||
| 20 | =head1 DESCRIPTION | ||
| 21 | |||
| 22 | A FormFu Validator to ensure that a user can't load an image with a name longer than 50 characters using the Image entity. | ||
| 23 | |||
| 24 | Images are not renamed when loaded in Strehler and their names are saved in the database. Database field for image name can't afford names longer than 50 characters. | ||
| 25 | |||
| 26 | This validator could be loaded using FormFu namespace, but for now I'll keep it in the Strehler distribution. | ||
| 27 | |||
| 28 | =head1 SYNOPSIS | ||
| 29 | |||
| 30 | In image form configuration: | ||
| 31 | |||
| 32 | elements: | ||
| 33 | - type: File | ||
| 34 | name: photo | ||
| 35 | label: Image | ||
| 36 | attributes: | ||
| 37 | class: span5 | ||
| 38 | validators: | ||
| 39 | - type: '+Strehler::FormFu::Validator::FilenameTooLong' | ||
| 40 | message: 'Filename is too long' | ||
| 41 | |||
| 42 | =cut | ||
| 43 | |||
| 44 | |||
| 45 | 1 | 1; | |