在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:jhthorsen/json-validator开源软件地址:https://github.com/jhthorsen/json-validator开源编程语言:Perl 99.7%开源软件介绍:JSON::ValidatorA module for validating data against a JSON Schema. use Mojolicious::Lite -signatures;
use JSON::Validator 'joi';
use Mojo::JSON qw(false to_json true);
post '/users' => sub ($c) {
my $user = $c->req->json;
# Validate input JSON document
my @errors = joi(
$user,
joi->object->props(
email => joi->email->required,
username => joi->string->min(1)->required,
password => joi->string->min(12)->required,
)
);
# Report back on invalid input
return $c->render(json => {errors => \@errors}, status => 400) if @errors;
# Handle the $user in some way
$c->app->log->info(to_json $user);
# Report back the status
return $c->render(json => {accepted => true}, status => 201);
};
app->start; InstallationAll you need is a one-liner, it takes seconds to install.
We recommend the use of a Perlbrew environment. Want to know more?Take a look at our excellent documentation! |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论