stripe-perl icon indicating copy to clipboard operation
stripe-perl copied to clipboard

create metadata TypeConstraint

Open sherrardb opened this issue 4 years ago • 1 comments

~$ perl -Mstrict -Mwarnings -mNet::Stripe -e 'my $stripe = Net::Stripe->new(api_key => $ENV{STRIPE_API_KEY});
my $source = $stripe->create_source(
  type=> "card",
  token=> "tok_visa",
  metadata => {
    somecardmetadata => "testing, testing, 1-2-3",
    nested=> {
      nested_key => "nested_value"
    },
  }
);'

produces:

{
  "error": {
    "message": "Invalid val: {:nested_key=\u003E\"nested_value\"} must be a string under 500 characters",
    "param": "metadata",
    "type": "invalid_request_error"
  }
}

i was testing for, and expected, an error for the nested value, but the information about the 500 character limit is a bonus.

i know that we can restrict to HashRef[Str], but i am not sure if we can restrict the Str to 500 characters using native Moose::Util::TypeConstraints parameters.

sherrardb avatar Feb 18 '20 15:02 sherrardb

in the interim, we can simply update all metadata to Maybe[HashRef[Str]

sherrardb avatar Feb 18 '20 16:02 sherrardb