Skip to content

Instantly share code, notes, and snippets.

@aerith
Created September 20, 2011 12:15
Show Gist options
  • Save aerith/1228954 to your computer and use it in GitHub Desktop.
Save aerith/1228954 to your computer and use it in GitHub Desktop.
package Asayake::Web::FormValidator::Post;
use strict;
use warnings;
use FormValidator::Lite;
my %post_validate_rule = (
user_id => [qw/NOT_NULL/],
blog_id => [qw/NOT_NULL/],
note_id => [qw/NOT_NULL/],
title => [qw/NOT_NULL/],
excerpt => [qw/NOT_NULL/],
published => [qw/NOT_NULL/],
status => [qw/NOT_NULL/]
);
sub validate_on_create {
my ($class, $c, @args) = @_;
my $result = FormValidator::Lite->new($c->req)->check(
%post_validate_rule,
);
$result;
}
sub validate_on_update {
my ($class, $c, @args) = @_;
my $result = FormValidator::Lite->new($c->req)->check(
%post_validate_rule,
id => [qw/NOT_NULL/]
);
$result;
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment