lib/Strehler/FormFu/Validator/UserUnique.pm

filter: Statementstmt 100% 20 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 96.3% 26 / 27 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/Strehler/FormFu/Validator/FilenameTooLong.pm ↑ Summary lib/Strehler.pm »
1 package Strehler::FormFu::Validator::UserUnique;
2 1 $Strehler::FormFu::Validator::UserUnique::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 1 ▶use Strehler::Element::User;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use base 'HTML::FormFu::Validator';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶sub validate_value {
Subroutine validate_value: called CC=1 SCAR=0.0
Pod undocumented
11 3 my ( $self, $value ) = @_;
12 3 my $user = Strehler::Element::User->get_from_username($value);
13 3 return ! $user;
14 }
15  
16 =encoding utf8
17  
18 =head1 NAME
19  
20 Strehler::FormFu::Validator::UserUnique - FormFu Validator for User form.
21  
22 =head1 DESCRIPTION
23  
24 A FormFu Validator to ensure that a user can't be created with a name already used.
25  
26 This validator hasn't the standard HTML::FormFu validators namespace because it makes sense only in a Strehler system.
27  
28 =head1 SYNOPSIS
29  
30 In user form configuration:
31  
32 - name: user
33 label: Username
34 attributes:
35 class: span8
36 validators:
37 - type: '+Strehler::FormFu::Validator::UserUnique'
38 message: 'Username already exists'
39 =cut
40  
41  
42 1 1;
« lib/Strehler/FormFu/Validator/FilenameTooLong.pm ↑ Summary lib/Strehler.pm »