PhilanthropyDataCommons / service

A project for collecting and serving public information associated with grant applications
GNU Affero General Public License v3.0
8 stars 2 forks source link

Validate primitive types using ajv formats #899

Closed hminsky2002 closed 6 months ago

hminsky2002 commented 7 months ago

Related to Issue #875 and Issue #760

the ajv-formats package offers type validation for primitive types, such as number, string, and boolean. We should implement this in the proposal field validation and anywhere else we are validating types.

slifty commented 6 months ago

@hminsky2002 you mentioned this in a zulip thread but wanted to bring it here -- I don't think we should be changing any of the values at this point (e.g. if coercion is resulting in value modification). This would mean we don't want to strip white space, change case, or change the format of the value that is going to be stored.

We should be storing exactly what the user gave us to store, but adding a flag as to whether its format met our expectations. We may add a "cleanup" step in a future date that attempts to correct the value they gave us.

bickelj commented 6 months ago

Probable duplicate of #308 (in addition to #760 being a dupe).

Regardless, huzzah, @hminsky2002!

slifty commented 6 months ago

For history's sake: this wasn't a duplicate, but an enhancement of the validation (we wanted to use ajv to do the validation, the initial implementation used regex)

bickelj commented 6 months ago

@slifty That makes sense, thanks!