| 1 | package Sah::Schema::currency::pair; | ||
| 2 | |||
| 3 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |
| 4 | 1 | our $DATE = '2020-03-08'; # DATE | |
| 5 | 1 | our $DIST = 'Sah-Schemas-Currency'; # DIST | |
| 6 | 1 | our $VERSION = '0.008'; # VERSION | |
| 7 | |||
| 8 | 1 | our $schema = [str => { | |
| 9 | summary => 'Fiat currency pair, e.g. USD/IDR', | ||
| 10 | description => <<'_', | ||
| 11 | |||
| 12 | Currency pair is string in the form of *currency1*/*currency2*, where | ||
| 13 | *currency1* is called the base currency while *currency2* is the quote (or | ||
| 14 | price) currency. Both must be known currency codes (e.g. USD, or IDR). | ||
| 15 | |||
| 16 | Currency code is checked against <pm:Locale::Codes::Currency_Codes>. | ||
| 17 | |||
| 18 | Will be normalized to uppercase. | ||
| 19 | |||
| 20 | _ | ||
| 21 | match => qr(\A\S+/\S+\z), | ||
| 22 | #'x.completion' => 'currency_pair', | ||
| 23 | 'x.perl.coerce_rules' => ['From_str::to_currency_pair'], | ||
| 24 | examples => [ | ||
| 25 | {value=>'', valid=>0}, | ||
| 26 | {value=>'idr', valid=>0}, | ||
| 27 | {value=>'usd/idr', valid=>1, validated_value=>'USD/IDR'}, | ||
| 28 | {value=>'usd idr', valid=>0}, | ||
| 29 | {value=>'usd/foo', valid=>0}, | ||
| 30 | ], | ||
| 31 | }, {}]; | ||
| 32 | |||
| 33 | 1 | 1; | |
| 34 | # ABSTRACT: Fiat currency pair, e.g. USD/IDR | ||
| 35 | |||
| 36 | __END__ |