Giter Club home page Giter Club logo

catalyst-actionrole-jsv's Introduction

NAME

Catalyst::ActionRole::JSV - A JSON Schema validator for Catalyst actions

SYNOPSIS

package MyApp::Controller::Item;
use Moose;
use namespace::autoclean;

BEGIN { extends 'Catalyst::Controller'; }

# RESTful API (Consumes type action) support by Catalyst::Runtime 5.90050 higher
__PACKAGE__->config(
    action => {
        '*' => {
            Consumes => 'JSON',
            Path => '', 
        }   
    }   
);


# Get info on a specific item
# GET /item/:item_id
sub lookup :GET Args(1) :Does(JSV) :JSONSchema(root/schema/lookup.json) {
    my ( $self, $c, $item_id ) = @_;
    my $params = $c->request->parameters;
    ...
}


# lookup.json (json schema draft4 validation)
{ 
    "title": "Lookup item",
    "type": "object",
    "properties": {
        "item_id": { 
            "type": "integer",
            "minLength": 1,
            "maxLength": 9, 
            "captureargs": 1  # In the case of URL CaptureArgs
        },   
        "paramX": { 
            "type": "string",
            "minLength": 8,
            "maxLength": 12  
        }, 
    },  
    "required": ["item_id"]
} 

DESCRIPTION

Catalyst::ActionRole::JSV is JSON Schema validator for Catalyst actions. Internally use the json schema draft4 validator called JSV.

Error Response

On error it returns 400 http response status. The stash key to set the error message is 'View::JSON expose_stash' key. The default key if omitted is 'json'.

$c->stash->{'View::JSON expose_stash key'} = {message => 'JSV->validate->get_error'}

myapp.yml config

name: MyApp
View::JSON:
    expose_stash: 'json'

SEE ALSO

AUTHOR

Masaaki Saito [email protected]

COPYRIGHT

Copyright 2017- Masaaki Saito

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

catalyst-actionrole-jsv's People

Contributors

manwar avatar masakyst avatar

Watchers

 avatar  avatar

Forkers

manwar

catalyst-actionrole-jsv's Issues

type number

number時も文字列としてではなく数値に変換させる必要がある

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.