*[View source on GitHub](https://github.com/PhilanthropyDataCommons/service/blob/1d0e73a0590f3e6041c0a8ebe26004907ea58869/docs/DATA_VALIDATION.md)*
# Base field datatype validation
PDC fields are validated on the basis of `baseField.dataType` (separate from `inputType`, see more [here](../application_rendering_hints)). This document provides more detail on how different data types are validated within PDC.
## Approach
PDC does not modify, normalize, trim, or otherwise change any of the data that it receives, stores, and retrieves. Instead, data validation provides users with the expectation of well-formatted data only for field values accompanied by `isValid: true`.
This means all values with leading or trailing whitespace will be considered invalid.
Where possible, we have used existing libraries for data validation.
– [ajv](https://github.com/ajv-validator/ajv)
– [validator](https://github.com/validatorjs/validator.js)
## Data types
| Data type | Validator | Notes |
| —————- | ———– | ——————————————————————- |
| `boolean` | | |
| `number` | | |
| `string` | ajv | |
| `email` | ajv | |
| `url` | ajv | |
| `date` | ajv | Full date per [RFC3339][1] |
| `date_time` | ajv | Must include timezone |
| `currency` | validator | |
| `phone_number` | validator | Extensions must be preceded by `;ext=` per [RFC3966][2] or commas |
| `file` | | [Read more](../add_fieldvalue_attachment) |
| —————- | ———– | ——————————————————————- |
[1]: http://tools.ietf.org/html/rfc3339#section-5.6
[2]: https://www.rfc-editor.org/rfc/rfc3966#section-3
*This content was automatically generated from [GitHub](https://github.com/PhilanthropyDataCommons/service/blob/1d0e73a0590f3e6041c0a8ebe26004907ea58869/docs/DATA_VALIDATION.md). Any edits made on WordPress will be lost.*
View source on GitHub
Base field datatype validation
PDC fields are validated on the basis of baseField.dataType (separate from inputType, see more here). This document provides more detail on how different data types are validated within PDC.
Approach
PDC does not modify, normalize, trim, or otherwise change any of the data that it receives, stores, and retrieves. Instead, data validation provides users with the expectation of well-formatted data only for field values accompanied by isValid: true.
This means all values with leading or trailing whitespace will be considered invalid.
Where possible, we have used existing libraries for data validation.
Data types
| Data type |
Validator |
Notes |
boolean |
|
|
number |
|
|
string |
ajv |
|
email |
ajv |
|
url |
ajv |
|
date |
ajv |
Full date per RFC3339 |
date_time |
ajv |
Must include timezone |
currency |
validator |
|
phone_number |
validator |
Extensions must be preceded by ;ext= per RFC3966 or commas |
file |
|
Read more |
| —————- |
———– |
——————————————————————- |
This content was automatically generated from GitHub. Any edits made on WordPress will be lost.