-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate field validators and associated tests to Typescript #7
Comments
Potential idea - do we want to refactor this away from class-based implementation to a functional implementation instead? the rationale being that validators are best implemented without having to hold state. also, we have good test coverage so it ought to be fairly safe to do so. |
Assigning to myself first to spearhead a sample FP implementation that should simplify what we have today. |
…ntations for section, short text & long text fields (#409) Email submission validators are crucial for preventing spoof submissions, and need to be migrated to TypeScript as part of push towards type safety. The existing implementation is problematic to port over however, due to * Type consistency * Misuse of the Inheritance pattern * Lack of Codebase clarity Solution * Composition over Inheritance - Encourage code reuse in order to compose larger validation functions from smaller ones. For example, Table validation can be composed from Text and Number validator functions. * Scaffolding for further migration - Perform full submission validation for all form field responses, instead of throwing an exception on a short-circuit basis upon encountering the first error that occurs. The hope is to use functional programming utilities so that all responses can be evaluated in order to obtain as much information as possible before rejecting a submission. Changes: * refactor: convert field-validation/index.ts and associated tests to typescript * refactor(field-validators): textFieldValidatorConstructor sectionValidatorConstructor * fix: only non-empty answers to be validated * refactor: delete AnswerNotAllowedValidator, TextValidator, unused PlaceholderValidator * refactor(ValidationOptions): Extract common validation options enum from short/long text fields, and use it in textValidator Addresses #7
self-assigning a couple first to get more chances to practice :) |
Migrate the field validators in
src/app/utils/field-validation
to TypeScript.As these validators affect email submissions directly, take care to keep existing logic and unit tests intact - and expand on them if necessary.
The text was updated successfully, but these errors were encountered: