Skip to content

Commit

Permalink
Tidy the SYNOPSIS, but skip syntax checking.
Browse files Browse the repository at this point in the history
  • Loading branch information
bleargh45 committed Jan 13, 2021
1 parent 2f7ba6e commit 31f0ad9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 41 deletions.
45 changes: 25 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,39 @@ use Data::FormValidator::Constraints::MethodsFactory qw(:set :num :bool);

# SET constraints (:set)
constraint_methods => {
status => FV_set(1, qw(new active disabled)),
how_many => FV_set_num(1, (1 .. 20)),
province => FV_set_word(1, "AB QC ON TN NU"),
seen_before => FV_set_cmp(1, sub { $seen{$_[0]} }, qw(foo bar)),
status => FV_set(1, qw(new active disabled)),
how_many => FV_set_num(1, (1 .. 20)),
province => FV_set_word(1, "AB QC ON TN NU"),
seen_before => FV_set_cmp(1, sub { $seen{ $_[0] } }, qw(foo bar)),
}

# NUMERIC constraints (:num)
constraint_methods => {
how_many => FV_clamp(1, 1, 10),
small_amount => FV_lt(1, 3),
large_amount => FV_gt(1, 10),
small_again => FV_le(1, 3),
large_again => FV_ge(1, 10),
how_many => FV_clamp(1, 1, 10),
small_amount => FV_lt(1, 3),
large_amount => FV_gt(1, 10),
small_again => FV_le(1, 3),
large_again => FV_ge(1, 10),
}

# BOOLEAN constraints (:bool)
constraint_methods => {
bad_status => FV_not(
FV_set(1, qw(new active disabled))
),
email => FV_or(
FV_set(1,$current_value),
Data::FormValidator::Constraints::email(),
),
password => FV_and(
FV_length_between(6,32),
my_password_validation_constraint(),
),
# e.g. NOT in the given set
bad_status => FV_not(
FV_set(1, qw(new active disabled))
),

# e.g. either the current value, OR validates as an e-mail address
email => FV_or(
FV_set(1, $current_value),
Data::FormValidator::Constraints::email(),
),

# e.g. valid length, AND matches password validation routine
password => FV_and(
FV_length_between(6, 32),
my_password_validation_constraint(),
),
}
```

Expand Down
1 change: 1 addition & 0 deletions dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ license = Perl_5
copyright_holder = Graham TerMarsch

[@Author::GTERMARS]
-remove = Test::Synopsis
48 changes: 27 additions & 21 deletions lib/Data/FormValidator/Constraints/MethodsFactory.pm
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ sub FV_and {

1;

=for stopwords MX num
=head1 NAME
Data::FormValidator::Constraints::MethodsFactory - Create constraints for Data::FormValidator
Expand All @@ -243,37 +245,41 @@ Data::FormValidator::Constraints::MethodsFactory - Create constraints for Data::
# SET constraints (:set)
constraint_methods => {
status => FV_set(1, qw(new active disabled)),
how_many => FV_set_num(1, (1 .. 20)),
province => FV_set_word(1, "AB QC ON TN NU"),
seen_before => FV_set_cmp(1, sub { $seen{$_[0]} }, qw(foo bar)),
status => FV_set(1, qw(new active disabled)),
how_many => FV_set_num(1, (1 .. 20)),
province => FV_set_word(1, "AB QC ON TN NU"),
seen_before => FV_set_cmp(1, sub { $seen{ $_[0] } }, qw(foo bar)),
}
# NUMERIC constraints (:num)
constraint_methods => {
how_many => FV_clamp(1, 1, 10),
small_amount => FV_lt(1, 3),
large_amount => FV_gt(1, 10),
small_again => FV_le(1, 3),
large_again => FV_ge(1, 10),
how_many => FV_clamp(1, 1, 10),
small_amount => FV_lt(1, 3),
large_amount => FV_gt(1, 10),
small_again => FV_le(1, 3),
large_again => FV_ge(1, 10),
}
# BOOLEAN constraints (:bool)
constraint_methods => {
bad_status => FV_not(
FV_set(1, qw(new active disabled))
),
email => FV_or(
FV_set(1,$current_value),
Data::FormValidator::Constraints::email(),
),
password => FV_and(
FV_length_between(6,32),
my_password_validation_constraint(),
),
# e.g. NOT in the given set
bad_status => FV_not(
FV_set(1, qw(new active disabled))
),
# e.g. either the current value, OR validates as an e-mail address
email => FV_or(
FV_set(1, $current_value),
Data::FormValidator::Constraints::email(),
),
# e.g. valid length, AND matches password validation routine
password => FV_and(
FV_length_between(6, 32),
my_password_validation_constraint(),
),
}
=head1 DESCRIPTION
C<Data::FormValidator::Constraints::MethodsFactory> provides a variety of
Expand Down

0 comments on commit 31f0ad9

Please sign in to comment.