Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

---

Expand Down
24 changes: 24 additions & 0 deletions examples/fields/BooleanSynonymField.md
Original file line number Diff line number Diff line change
@@ -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
62 changes: 62 additions & 0 deletions examples/fields/RegionFields.md
Original file line number Diff line number Diff line change
@@ -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'})
```