本文へ移動

address-plusアドレスプラス

住所を端末の中で解析・確認・整形・比較し、国のモジュールや任意のフォームの入力欄を使えます。

address-plusは、parse-addressの使い方を広げ、型付きの結果、確認、書式、国のモジュールを加えます。 名前について(英語)

目次

リファレンス

/br

import { … } from "@johnmorrisdotca/address-plus/br";

最小化と gzip 圧縮をしたサイズは 5.4 kB(読み込むものをすべて含み、esbuild で計測)

リファレンスの説明と例は英語です。見出しと目次は日本語です。

エクスポート

名前種類概要
BR_STATES定数The states of Brazil and the Federal District.
brazil定数Brazil's module, for parseLocation and validateAddress: pass it in countries, and an address that ends with Brazil, Brasil or BR, or with a CEP written with its hyphen in the range of a state after CEP or a state's code, is read as Brazilian; country: "BR" reads any address as one.
BrazilianPostFormattingOptions型Options for formatBrazilianPost.
compareBrazilianAddresses関数Compares two addresses in Brazil field by field: the street, its number, the complement, the bairro's city and the CEP.
CountryComparison型What a country module's comparer returns: whether the two addresses are the same delivery point, and every field that differs once both are in the same form (letter case, punctuation, a street type written out or abbreviated).
CountryDifference型One way two addresses differ, as a country module's comparer reports it: the field, and its value in each address after both were put in the same form.
CountryModule型A country's address module: its codes, how to tell its addresses apart, and its parser, validator, formatter and comparer.
CountryValidation型What a country module's validator returns: the errors and the warnings it found.
findBrazilianState関数Finds a state of Brazil by its code (SP, BR-SP) or its name in English or Portuguese, ignoring accents and letter case.
formatBrazilianPost関数Writes an address in Brazil as the Correios ask: who it is care of, the street with its number and the complement (Avenida Paulista, 1578, Apto 45), the bairro, then the CEP, the city and the state's code, each on its own line.
FormattedAddress型A formatted address: its lines, and the same on one line.
getStateFromBrazilianPostcode関数The state a CEP is in, by its code (SP): the state whose range holds the CEP's first five digits.
isKnownBrazilianPostcode関数Whether a CEP is in a range the Correios gave a state: it has the shape and its first five digits fall in a state's range.
isValidBrazilianPostcode関数Whether a CEP follows the Correios' shape: eight digits, with a hyphen after the fifth or none.
looksBrazilian関数Whether an address is surely Brazilian, with no hint: it ends with Brazil, Brasil or BR, or with a CEP written with its hyphen (01310-200, five digits, a hyphen and three) in the range of a state, after the word CEP or a Brazilian state's code (SP).
parseBrazilianAddress関数Parses an address in Brazil into the parts the Correios lay out: who it is care of (careOf), the street as written with its type (street: Avenida Paulista, `R.
ParsedAddress型What parseLocation returns: every part it found, each absent when the address has none.
ParseOptions型Options for every parser: the country, strict postal codes, snake_case keys and the rest.
PostcodeLookup型A postcode taken apart: its canonical form, the region it is in (when the country's table has regions), and whether the country's list has it.
PostcodeRegion型A region a postcode can be in, as a country's table holds it: its code, its ISO 3166-2 code, and its name in English and in Japanese (from kuni, which takes them from Unicode CLDR and Wikidata).
validateBrazilianAddress関数Checks an address in Brazil: the CEP is eight digits and in a range the Correios gave a state, the state written agrees with the CEP's, and the city and the street's number are given.
ValidationError型One finding of a validator: the field it is about, its code, a message, and how serious it is.
ValidationOptions型Options for the validators: which parts an address must have, which kinds are allowed, and whether a postal code that does not match its region is an error.

ソースを見るGitHub で編集@johnmorrisdotca/address-plus 1.10.2 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。