Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type_maybe + type_hash doesn't work #3

Closed
tokuhirom opened this issue Apr 28, 2017 · 0 comments
Closed

type_maybe + type_hash doesn't work #3

tokuhirom opened this issue Apr 28, 2017 · 0 comments

Comments

@tokuhirom
Copy link
Owner

use strict;
use warnings;
use utf8;

use Test::More;
use ThaiSchema::JSON;
use ThaiSchema;

my $json = q/{"prop": {"subprop": 1}}/;
my $null_json = q/{"prop": null}/;

my $schema = +{
    prop => type_maybe(type_hash(+{
        subprop => type_int
    }))
};

my $j = ThaiSchema::JSON->new();

{
    # This test will pass.
    my ($ok, $errors) = $j->validate($null_json, $schema);
    ok($ok);
    diag($_) for @$errors;
}

{
    # This test case will fail.
    # at ThaiSchema.t line 32.
    # Can't locate object method "schema" via package "ThaiSchema::Maybe"
    #   at /Library/Perl/5.18/ThaiSchema/JSON.pm line 190.
    # でこける。
    my ($ok, $errors) = $j->validate($json, $schema);
    ok($ok);
    diag($_) for @$errors;
}
done_testing;
tokuhirom added a commit that referenced this issue May 8, 2017
type_maybe(type_hash) should work. close #3
tokuhirom added a commit that referenced this issue May 8, 2017
Changelog diff is:

diff --git Changes Changes
index 8ed7d83..2232f2b 100644
--- Changes
+++ Changes
@@ -2,6 +2,17 @@ Revision history for Perl module ThaiSchema

 {{$NEXT}}

+0.10 2017-05-08T01:28:43Z
+
+    commit 1ca3621
+    Merge: 2959412 7247e2f
+    Author: Tokuhiro Matsuno <tokuhirom@gmail.com>
+    Date:   Mon May 8 10:26:11 2017 +0900
+
+        Merge pull request #4 from tokuhirom/fix-issue-3
+
+        type_maybe(type_hash) should work. close #3.
+
 0.09 2013-09-02T03:22:39Z

     - Oops. Older version things 0 as invalid integer in non-strict mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant