Skip to content

Commit a40df5c

Browse files
authored
Merge pull request #30 from dwyl/update-readme
#29 Updates readme field types and gives html_sanitize info
2 parents a979abb + ee31b0e commit a40df5c

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

Diff for: README.md

+20-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
https://youtu.be/KLVq0IAzh1A
33

44

5-
A collection of commonly used fields implemented as custom Ecto types with the necessary validation, encryption, and/or hashing.
5+
A collection of commonly used fields implemented as custom Ecto types with the necessary validation, encryption, and/or hashing.
66

77

88
## Installation
@@ -41,27 +41,38 @@ Each field is defined as an [Ecto type](https://hexdocs.pm/ecto/Ecto.Type.html),
4141

4242
When you load one of the fields into your database, the corresponding `dump/1` callback will be called, ensuring it is inserted into the database in the correct format. In the case of `Fields.EmailEncrypted`, it will encrypt the email address using a give encryption key (set in your config file) before inserting it.
4343

44-
Likewise, when you load a field from the database, the `load/1` callback will be called, giving you the data in the format you need. `Fields.EmailEncrypted` will be decrypted back to plaintext.
44+
Likewise, when you load a field from the database, the `load/1` callback will be called, giving you the data in the format you need. `Fields.EmailEncrypted` will be decrypted back to plaintext.
4545

4646
Each Field optionally defines an `input_type/0` function. This will return an atom representing the `Phoenix.HTML.Form` input type to use for the Field. For example, `Fields.DescriptionPlaintextUnlimited.input_type` returns `:textarea`.
4747

48+
The fields `DescriptionPlaintextUnlimited` and `HtmlBody` use html_sanitize_ex
49+
(https://github.com/rrrene/html_sanitize_ex) to remove scripts and help keep your
50+
project safe. `HtmlBody` is able to display basic html elements whilst
51+
`DescriptionPlaintextUnlimited` displays text. Remember to use `raw` when rendering
52+
the content of your `DescriptionPlaintextUnlimited` and `HtmlBody` fields so that
53+
symbols such as & (ampersand) and Html are rendered correctly. E.g.
54+
`<p><%= raw @product.description %></p>`
55+
4856
The currently existing fields are:
4957

58+
- [Address](lib/address.ex)
59+
- [AddressEncrypted](lib/address_encrypted.ex)
60+
- [DescriptionPlaintextUnlimited](lib/description_plaintext_unlimited.ex)
5061
- [Encrypted](lib/encrypted.ex)
51-
- [Hash](lib/hash.ex)
5262
- [EmailPlaintext](lib/email_plaintext.ex)
5363
- [EmailHash](lib/email_hash.ex)
5464
- [EmailEncrypted](lib/email_encrypted.ex)
65+
- [Hash](lib/hash.ex)
66+
- [HtmlBody](lib/html-body.ex)
5567
- [Password](lib/password.ex)
56-
- [Postcode](lib/postcode.ex)
57-
- [PostcodeEncrypted](lib/postcode_encrypted.ex)
58-
- [Address](lib/address.ex)
59-
- [AddressEncrypted](lib/address_encrypted.ex)
6068
- [PhoneNumber](lib/phone_number.ex)
6169
- [PhoneNumberEncrypted](lib/phone_number_encrypted.ex)
62-
- [DescriptionPlaintextUnlimited](lib/description_plaintext_unlimited.ex)
70+
- [Postcode](lib/postcode.ex)
71+
- [PostcodeEncrypted](lib/postcode_encrypted.ex)
72+
- [Url](lib/url.ex)
73+
6374

64-
## Config
75+
## Config
6576

6677
If you use any of the `Encrypted` fields, you will need to set a list of one or more encryption keys in your config:
6778

0 commit comments

Comments
 (0)