diff --git a/README.md b/README.md index d1ff08a..7aac892 100644 --- a/README.md +++ b/README.md @@ -400,6 +400,8 @@ When releasing pieces to the SDK our thought process is guided by the following Links to more in-depth documentation we have written about features. * [SmartDateField](./examples/fields/SmartDateField.README.md) +* [RegionFields CountryField and StateField](./examples/fields/RegionFields.README.md) +* [BooleanSynonymField](./examples/fields/BooleanSynonymField.README.md) --- diff --git a/examples/fields/BooleanSynonymField.md b/examples/fields/BooleanSynonymField.md new file mode 100644 index 0000000..8a2b495 --- /dev/null +++ b/examples/fields/BooleanSynonymField.md @@ -0,0 +1,24 @@ +# BooleanSynonymField + +BooleanSynonymField lets you specify custom synonyms for boolean values. This need is so common we decided to encapsulate the logic into a field + +## Use +``` +spanishBoolean : BooleanSynonymField({ + trueSubstitutes: ['si', 'affirmative'], + falseSubstitutes: ['nay', 'non'], + }) +``` + +how does our field behave +| raw | output | +|:------------|:-------| +| si | true | +| true | true | +| yes | true | +| affirmative | true | +| nay | false | +| non | false | + + +"yes" and "true" return `true` because BooleanSynonymField augments the base BooleanField diff --git a/examples/fields/RegionFields.md b/examples/fields/RegionFields.md new file mode 100644 index 0000000..0924ecc --- /dev/null +++ b/examples/fields/RegionFields.md @@ -0,0 +1,62 @@ +# RegionFields + +`CountryField` and `StateField` are two region fields. Both fields convert between common formats. + +## StateField +StateField outputs a state in two formats - `two-letter` or `full`. + + +### `two-letter` +| raw | output | +|:--------|:-------| +| ak | AK | +| MS | MS | +| Ri | RI | +| Alabama | AL | + +### `full` +| raw | output | +|:--------|:-------------| +| ak | Alaska | +| MS | Mississippi | +| Ri | Rhode Island | +| Alabama | Alabama | + +Instantiate StateField as follows +``` +state: StateField({ stateFormat: 'two-letter' }) +``` + +## CountryField + +CountryField has three options for `countryFormat` - `iso-2`, `iso-3`, `full` + +### `iso-2` +| raw | output | +|:-------|:-------| +| us | US | +| USA | US | +| USa | US | +| France | FR | + +### `iso-3` +| raw | output | +|:-------|:-------| +| us | USA | +| USA | USA | +| USa | USA | +| France | FRA | + +### `full` +| raw | output | +|:-------|:-------------------------| +| us | United States of America | +| USA | United States of America | +| USa | United States of America | +| France | France | + + +Instantiate `CountryField` like this +``` +country: CountryField({'countryFormat':'iso-2'}) +```