Closed hminsky2002 closed 4 months ago
@slifty pushed some changes here, but wanted to wait for your feedback on the boolean validation:
function isValidBoolean(bool: string): boolean {
// Converting to lower case to abide by ajv's coercion rules
const formattedBoolean = bool.toLowerCase();
const booleanSchema = {
type: 'boolean',
};
return ajv.validate(booleanSchema, formattedBoolean);
}
Let's not make any changes to the values before (or while) validating -- the goal here isn't to ensure maximial passage, it's to define a reasonable specification and test against it. I think that using ajv's specification is fine (and probably is driven by a standard somewhere), and if something doesn't pass it then it simply doesn't pass.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 88.21%. Comparing base (
f43cd9d
) to head (3f222b4
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This PR rids us of the last of the hard-coded regex's used in type validation of proposal field values. It utilizes the primitive type validation in ajv to validate numbers and booleans. It follows the pattern in PR #914 of refactoring the
fieldValueIsValid
function to use a series of validation functions, instead of performing the validation itself.Closes #899