NAME
FormValidator::Simple::ProfileManager::YAML - YAML profile manager for FormValidator::Simple
SYNOPSIS
use FormValidator::Simple;
use FormValidator::Simple::ProfileManager::YAML;
my $manager = FormValidator::Simple::ProfileManager::YAML->new('/path/to/profile.yml');
# get profile assosiated with @groups
my $profile = $manager->get_profile(@groups);
# pass obtained profile to FormValidator::Simple
my $result = FormValidator::Simple->check($q, $profile);
# create new manager associated with group
my $manager2 = $manager->extract(@groups);
# you can add profile to @groups
$manager->add_profile(
email => [EMAIL],[NOT_BLANK],
@groups,
);
# and also you can remove profile from @groups
$manager->remove_profile(email, @groups);
# sample yaml profile
group1 :
- name
- [ [NOT_BLANK] ]
- email
- [ [NOT_BLANK], [EMAIL_LOOSE] ]
- tel
- [ [NOT_BLANK], [NUMBER_PHONE_JP] ]
- content
- [ [NOT_BLANK] ]
group2 :
subgroup1 :
- userid
- [ [NOT_BLANK]]
- password
- [ [NOT_BLANK]]
- name
- [ [NOT_BLANK] ]
- email
- [ [NOT_BLANK], [EMAIL_LOOSE] ]
subgroup2 :
- tel
- [ [NOT_BLANK], [NUMBER_PHONE_JP] ]
- { zip : [zip1, zip2] }
- [ [ZIP_JP] ]
- address
- [ [NOT_BLANK] ]
# get profile 'group1'
$profile = $manager->get_profile('group1');
# get profile 'subgroup2'
$profile = $manager->get_profile( 'group2', 'subgroup2' );
# or you can use dot syntax.
$profile = $manager->get_profile( 'group2.subgroup2' );
# Default YAML loader is 'YAML'.
# If you want to use 'YAML::Syck' as loader, pass 'loader' to constructor as below.
my $manager = FormValidator::Simple::ProfileManager::YAML->new(
'/path/to/profile.yml',
{
loader => 'YAML::Syck',
}
);
DESCRIPTION
FormValidator::Simple::ProfileManager::YAML is YAML profile manager for FormValidator::Simple.
METHODS
- new
-
$manager = FormValidator::Simple::ProfileManager::YAML->new('/path/to/profile.yml'); $manager = FormValidator::Simple::ProfileManager::YAML->new('/path/to/profile.yml', {loader=>'YAML::Syck'});
- get_profile
-
$profile = $manager->get_profile(); $profile = $manager->get_profile('group1'); $profile = $manager->get_profile('group1', 'subgroup2'); $profile = $manager->get_profile('group1.subgroup2');
- extract
-
my $manager2 = $manager->extract(@group);
- add_profile
-
$manager->add_profile( email => [EMAIL],[NOT_BLANK], @groups, );
- remove_profile
-
$manager->remove_profile(email, @groups);
AUTHOR
Yasuhiro Horiuchi <yasuhiro@hori-uchi.com>