Result:
found 99 distributions and 284 files matching your query ! ( run in 0.989 )


Mojolicious-Plugin-TrustedProxy

 view release on metacpan or  search on metacpan

lib/Mojolicious/Plugin/TrustedProxy.pm  view on Meta::CPAN

Mojolicious app is directly exposed to the internet, or if it sits behind
multiple upstream proxies. You should therefore ensure your application does
not enable the default Mojolicious reverse proxy handler when using this plugin.

This plugin supports parsing L<RFC 7239|http://tools.ietf.org/html/rfc7239>
compliant C<Forwarded> headers, validates all IP addresses, and will
automatically convert RFC-4291 IPv4-to-IPv6 mapped values (useful for when your
Mojolicious listens on both IP versions). Please be aware that C<Forwarded>
headers are only partially supported. More information is available in L</BUGS>.

Debug logging can be enabled by setting the C<MOJO_TRUSTEDPROXY_DEBUG>

 view all matches for this distribution
 view release on metacpan -  search on metacpan

Mojolicious-Plugin-Validate-Tiny

 view release on metacpan or  search on metacpan

lib/Mojolicious/Plugin/Validate/Tiny.pm  view on Meta::CPAN

            my ( $c, $rules, $params ) = @_;
            
            croak "ValidateTiny: Wrong validatation rules"
                if (none {$_ eq ref($rules)} ('ARRAY', 'HASH'));

            $c->flash('validate_tiny.was_called', 1);

            $rules = { checks => $rules } if ref $rules eq 'ARRAY';
            $rules->{fields} ||= [];

            # Validate GET+POST parameters by default

lib/Mojolicious/Plugin/Validate/Tiny.pm  view on Meta::CPAN


                    my $errors = {};
                    foreach my $f (@fields_wo_rules) {
                        $errors->{$f} = "No validation rules for field \"$f\"";
                    }
                    $c->flash('validate_tiny.errors' => $errors);
                    $log->debug($err_msg);
                    return 0;
                }
            }

lib/Mojolicious/Plugin/Validate/Tiny.pm  view on Meta::CPAN

            }
            else { # Fall back for old Validate::Tiny version
                $result = Validate::Tiny->new( $params, $rules );
            }
            
            $c->flash('validate_tiny.result' => $result);

            if ( $result->success ) {
                $log->debug('ValidateTiny: Successful');
                return $result->data;
            } else {
                $log->debug( 'ValidateTiny: Failed: ' . join( ', ', keys %{ $result->error } ) );
                $c->flash('validate_tiny.errors' => $result->error);
                return;
            }
        } );

    # Helper validator_has_errors
    $app->helper(
        validator_has_errors => sub {
            my $c      = shift;
            my $errors = $c->flash('validate_tiny.errors');

            return 0 if !$errors || !keys %$errors;
            return 1;
        } );

    # Helper validator_error
    $app->helper(
        validator_error => sub {
            my ( $c, $name ) = @_;
            my $errors = $c->flash('validate_tiny.errors');

            return $errors unless defined $name;

            if ( $errors && defined $errors->{$name} ) {
                return $errors->{$name};

lib/Mojolicious/Plugin/Validate/Tiny.pm  view on Meta::CPAN

        validator_error_string => sub {
            my ( $c, $params ) = @_;
            return '' unless $c->validator_has_errors();
            $params //= {};

            return $c->flash('validate_tiny.result')->error_string(%$params);
        } );

    # Helper validator_any_error
    $app->helper(
        validator_any_error => sub {
            my ( $c ) = @_;
            my $errors = $c->flash('validate_tiny.errors');

            if ( $errors ) {
                return ( ( values %$errors )[0] );
            }

lib/Mojolicious/Plugin/Validate/Tiny.pm  view on Meta::CPAN

    # Print info about actions without validation
    $app->hook(
        after_dispatch => sub {
            my ($c) = @_;

            return 1 if $c->flash('validate_tiny.was_called');

            my $stash = $c->stash;

            if ( $stash->{controller} && $stash->{action} ) {
                $log->debug("ValidateTiny: No validation in [$stash->{controller}#$stash->{action}]");

lib/Mojolicious/Plugin/Validate/Tiny.pm  view on Meta::CPAN

    # Mojolicious::Lite
    plugin 'Validate::Tiny';
    
    sub action { 
        my $self = shift;
        my $validate_rules = [
            # All of these are required
            [qw/name email pass pass2/] => is_required(),

            # pass2 must be equal to pass
            pass2 => is_equal('pass'),

            # custom sub validates an email address
            email => sub {
                my ( $value, $params ) = @_;
                Email::Valid->address($value) ? undef : 'Invalid email';
            }
        ];
        return unless $self->do_validation($validate_rules);
        
        ... Do something ...
    }
        
        
    sub action2 {
        my $self = shift;

        my $validate_rules = { 
            checks  => [...],
            fields  => [...],
            filters => [...]
        };
        if ( my $filtered_params =  $self->do_validation($validate_rules) ) {
            # all $params are validated and filters are applyed
            ... do your action ...

         
        } else {
            my $errors     = $self->validator_error;             # hash with errors

 view all matches for this distribution
 view release on metacpan -  search on metacpan

Mojolicious-Plugin-ValidateMoose

 view release on metacpan or  search on metacpan

lib/Mojolicious/Plugin/ValidateMoose.pm  view on Meta::CPAN

package Mojolicious::Plugin::ValidateMoose;

=head1 NAME

Mojolicious::Plugin::ValidateMoose - Can validate using Moose objects

=head1 VERSION

0.02

=head1 DESCRIPTION

This module is handy if you want to validate POST/GET parameters
using L<Moose> classes.

=head1 SYNOPSIS

    package MyApp;

lib/Mojolicious/Plugin/ValidateMoose.pm  view on Meta::CPAN

    use Mojo::Base 'Mojolicious::Controller';
    sub foo {
        my $self = shift;

        if($self->req->method eq 'POST') {
            if(my $obj = $self->validate_moose('My::Moose::Class')) {
                # input validate, and $obj created from My::Moose::Class
                # with the params set as attributes
            }
        }
    }

lib/Mojolicious/Plugin/ValidateMoose.pm  view on Meta::CPAN


our $VERSION = eval '0.02';

=head1 HELPERS

=head2 validate_moose

    $obj = $controller->validate_moose($moose_class, \%args);
    $obj = $controller->validate_moose($moose_obj, \%args);

Will either update an existing or create a new L<Moose> object, if all
the attributes gets validated. If any of the attributes is not updated
with the right value from C<param()>, this method will set
C<invalid_form_elements> in the stash to a datastructure like this:

    {
        $param_name_a => 'required', # fixed

lib/Mojolicious/Plugin/ValidateMoose.pm  view on Meta::CPAN


Example moose exception message:

    Validation failed for 'Int' with value "asd"

The method will return empty list if it fail to validate the input.

=cut

sub validate_moose {
    my($c, $class, $args) = @_;
    my $obj = ref $class ? $class : undef;
    my $meta = $class->meta;
    my(%constructor_args, %invalid);

lib/Mojolicious/Plugin/ValidateMoose.pm  view on Meta::CPAN

=cut

sub register {
    my($self, $app, $config) = @_;

    $app->helper(validate_moose => \&validate_moose);
}

=head1 COPYRIGHT & LICENSE

This library is free software. You can redistribute it and/or modify

 view all matches for this distribution
 view release on metacpan -  search on metacpan

Mojolicious-Plugin-ValidateTiny

 view release on metacpan or  search on metacpan

lib/Mojolicious/Plugin/ValidateTiny.pm  view on Meta::CPAN

        do_validation => sub {
            my ( $c, $rules, $params ) = @_;
            croak "ValidateTiny: Wrong validatation rules"
                unless ref($rules) ~~ [ 'ARRAY', 'HASH' ];

            $c->stash('validate_tiny.was_called', 1);

            $rules = { checks => $rules } if ref $rules eq 'ARRAY';
            $rules->{fields} ||= [];

            # Validate GET+POST parameters by default

lib/Mojolicious/Plugin/ValidateTiny.pm  view on Meta::CPAN


                    my $errors = {};
                    foreach my $f (@fields_wo_rules) {
                        $errors->{$f} = "No validation rules for field \"$f\"";
                    }
                    $c->stash( 'validate_tiny.errors' => $errors);
                    $log->debug($err_msg);
                    return 0;
                }
            }

lib/Mojolicious/Plugin/ValidateTiny.pm  view on Meta::CPAN

            }
            else { # Fall back for old Validate::Tiny version
                $result = Validate::Tiny->new( $params, $rules );
            }
            
            $c->stash( 'validate_tiny.result' => $result );

            if ( $result->success ) {
                $log->debug('ValidateTiny: Successful');
                return $result->data;
            } else {
                $log->debug( 'ValidateTiny: Failed: ' . join( ', ', keys %{ $result->error } ) );
                $c->stash( 'validate_tiny.errors' => $result->error );
                return;
            }
        } );

    # Helper validator_has_errors
    $app->helper(
        validator_has_errors => sub {
            my $c      = shift;
            my $errors = $c->stash('validate_tiny.errors');

            return 0 if !$errors || !keys %$errors;
            return 1;
        } );

    # Helper validator_error
    $app->helper(
        validator_error => sub {
            my ( $c, $name ) = @_;
            my $errors = $c->stash('validate_tiny.errors');

            return $errors unless defined $name;

            if ( $errors && defined $errors->{$name} ) {
                return $errors->{$name};

lib/Mojolicious/Plugin/ValidateTiny.pm  view on Meta::CPAN

        validator_error_string => sub {
            my ( $c, $params ) = @_;
            return '' unless $c->validator_has_errors();
            $params //= {};

		    return $c->stash('validate_tiny.result')->error_string(%$params);
        } );

    # Helper validator_any_error
    $app->helper(
        validator_any_error => sub {
            my ( $c ) = @_;
            my $errors = $c->stash('validate_tiny.errors');

            if ( $errors ) {
                return ( ( values %$errors )[0] );
            }

lib/Mojolicious/Plugin/ValidateTiny.pm  view on Meta::CPAN

    # Print info about actions without validation
    $app->hook(
        after_dispatch => sub {
            my ($c) = @_;
            my $stash = $c->stash;
            return 1 if $stash->{'validate_tiny.was_called'};

            if ( $stash->{controller} && $stash->{action} ) {
                $log->debug("ValidateTiny: No validation in [$stash->{controller}#$stash->{action}]");
                return 0;
            }

lib/Mojolicious/Plugin/ValidateTiny.pm  view on Meta::CPAN

    # Mojolicious::Lite
    plugin 'ValidateTiny';

    sub action {
        my $self = shift;
        my $validate_rules = [
             # All of these are required
             [qw/name email pass pass2/] => is_required(),

             # pass2 must be equal to pass
             pass2 => is_equal('pass'),

             # custom sub validates an email address
             email => sub {
                my ( $value, $params ) = @_;
                Email::Valid->address($value) ? undef : 'Invalid email';
             }
        ];
        return unless $self->do_validation($validate_rules);

        ... Do something ...
    }


    sub action2 {
        my $self = shift;

        my $validate_rules = {
            checks  => [...],
            fields  => [...],
            filters => [...]
        };
        if ( my $filtered_params =  $self->do_validation($validate_rules) ) {
            # all $params are validated and filters are applyed
            ... do your action ...


        } else {
            my $errors     = $self->validator_error;             # hash with errors

 view all matches for this distribution
 view release on metacpan -  search on metacpan

Mojolicious-Plugin-Vparam

 view release on metacpan or  search on metacpan

lib/Mojolicious/Plugin/Vparam.pm  view on Meta::CPAN

Full Mojolicious::Validator::Validation integration

=back

This module use simple parameters types B<str>, B<int>, B<email>, B<bool>,
etc. to validate.
Instead of many other modules you mostly not need add specific validation
subs or rules.
Just set parameter type. But if you want sub or regexp you can do it too.

=head1 SYNOPSIS

lib/Mojolicious/Plugin/Vparam.pm  view on Meta::CPAN

    <input name="myparam" value="<%= vvalue 'myparam' %>">

    # Return next code if user just open form without submit and validation:
    # <input name="myparam" value="">

    # Then user submit form and you validate id. For example user submit "abc":
    # <input name="myparam" value="abc">

=head2 vtype $name, %opts

Set new type $name if defined %opts. Else return type $name definition.

lib/Mojolicious/Plugin/Vparam.pm  view on Meta::CPAN

Simple objects via parameters (without validation!). Example:

# {foo => [ {bar => 1, baz => 2} ]}
?param1[foo][0][bar]=1&param1[foo][0][baz]=2

This is experimental feature. We think how to validate parameters.

=head1 ATTRIBUTES

You can set a simple mode as in example or full mode. Full mode keys:

lib/Mojolicious/Plugin/Vparam.pm  view on Meta::CPAN

formatted scalar.

=head2 jpath or jpath?

If you POST data not form but raw JSON you can use JSON Pointer selectors
from L<Mojo::JSON::Pointer> to get and validate parameters.

    # POST data contains:
    # {"point":{"address":"some", "lon": 45.123456, "lat": 38.23452}}

    %opts = $self->vparams(

 view all matches for this distribution
 view release on metacpan -  search on metacpan

Mojolicious-Plugin-Web-Auth

 view release on metacpan or  search on metacpan

lib/Mojolicious/Plugin/Web/Auth.pm  view on Meta::CPAN

      on_finished => sub {
          my ( $c, $access_token, $user_info ) = @_;
          ...
      };

=head2 C<validate_state>

Optional: OAuth 2.0 only. Default value is 1, see L<http://tools.ietf.org/html/rfc6819#section-5.3.5>.


=head2 C<on_finished>

 view all matches for this distribution
 view release on metacpan -  search on metacpan

Mojolicious-Plugin-WebPush

 view release on metacpan or  search on metacpan

lib/Mojolicious/Plugin/WebPush.pm  view on Meta::CPAN

  my ($subs_session2user_p, $subs_create_p) = @_;
  sub {
    my ($c) = @_;
    my ($decode_ok, $body) = _decode($c->req->body);
    return _error($c, $body) if !$decode_ok;
    eval { validate_subs_info($body) };
    return _error($c, $@) if $@;
    return $subs_session2user_p->($c, $c->session)->then(
      sub { $subs_create_p->($c, $_[0], $body) },
    )->then(
      sub { $c->render(json => { data => { success => \1 } }) },

lib/Mojolicious/Plugin/WebPush.pm  view on Meta::CPAN

sub register {
  my ($self, $app, $conf) = @_;
  my @config_errors = grep !exists $conf->{$_}, @MANDATORY_CONF;
  die "Missing config keys @config_errors\n" if @config_errors;
  $app->helper('webpush.create_p' => sub {
    eval { validate_subs_info($_[2]) };
    return Mojo::Promise->reject($@) if $@;
    goto &{ $conf->{subs_create_p} };
  });
  $app->helper('webpush.read_p' => $conf->{subs_read_p});
  $app->helper('webpush.delete_p' => $conf->{subs_delete_p});

lib/Mojolicious/Plugin/WebPush.pm  view on Meta::CPAN

    push => $conf->{push_handler} || $DEFAULT_PUSH_HANDLER
  );
  $self;
}

sub validate_subs_info {
  my ($info) = @_;
  die "Expected object\n" if ref $info ne 'HASH';
  my @errors = map "no $_", grep !exists $info->{$_}, qw(keys endpoint);
  push @errors, map "no $_", grep !exists $info->{keys}{$_}, qw(auth p256dh);
  die "Errors found in subscription info: " . join(", ", @errors) . "\n"

 view all matches for this distribution
 view release on metacpan -  search on metacpan

Mojolicious-Plugin-Webpack

 view release on metacpan or  search on metacpan

t/package-lock.json  view on Meta::CPAN

      "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
      "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
      "dev": true,
      "bin": {
        "esparse": "bin/esparse.js",
        "esvalidate": "bin/esvalidate.js"
      },
      "engines": {
        "node": ">=4"
      }
    },

 view all matches for this distribution
 view release on metacpan -  search on metacpan

Mojolicious-Static-Role-Compressed

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

t/asset_memory.t
t/author-pod-syntax.t
t/basic.t
t/compression_types_lowercase.t
t/compression_types_setter.t
t/compression_types_validate.t
t/content_type.t
t/if_none_match.t
t/lib/TestHelpers.pm
t/public/compressed_one_larger.txt
t/public/compressed_one_larger.txt.br

MANIFEST  view on Meta::CPAN

t/serve.t
t/serve_asset.t
t/serve_file.t
t/should_serve_asset.t
t/should_serve_asset_setter.t
t/should_serve_asset_validate.t

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.989 second using v1.01-cache-2.11-cpan-0b5f733616e )