LG-10760: refactor validations for DocPiiForm#9469
Conversation
| end | ||
| end | ||
|
|
||
| context 'when there is an invalid state' do |
There was a problem hiding this comment.
Thanks for adding this context block. 👍🏻
| @form_response.errors.except(:hints).flat_map do |key, errs| | ||
| form_response_errors = @form_response.errors.clone | ||
| if form_response_errors.many? { |k, v| %i[name dob dob_min_age state].include?(k) } | ||
| form_response_errors = { pii: [I18n.t('doc_auth.errors.general.no_liveness')] } |
There was a problem hiding this comment.
Another option is to deal this in the doc_pii_form, so it's the form's responsibility to deal with all this? On the otherhand, it is how you present his errors, so fine to me.
There was a problem hiding this comment.
@dawei-nava - yes, this consolidation seems to be more about what the FE receives. i did look at perforning this in the DocPIIForm but I figured this way allows us to be more explicit in our analytics and support
| expect(doc_auth_log.front_image_submit_count).to eq(count) | ||
| end | ||
|
|
||
| def pii_like_keypaths |
There was a problem hiding this comment.
Since this helper method is defined and used in three different spec files, I recommend consolidating and defining it in one file that stores helper methods.
| [:errors, :zipcode], [:error_details, :zipcode], | ||
| [:errors, :jurisdiction], [:error_details, :jurisdiction] | ||
| ] | ||
| end |
There was a problem hiding this comment.
Just for my own note, the pii_like_keypaths looks like following now, this explicitly tells FakeAnalytics that this nested hash keys are allowed entry when invoking track_event and there is no pii info exposed.
[[:pii], [:name, :dob, :dob_min_age, :address1, :state, :zipcode, :jurisdiction], [:errors, :name], [:error_details, :name], [:errors, :dob], [:error_details, :dob], [:errors, :dob_min_age], [:error_details, :dob_min_age], [:errors, :address1], [:error_details, :address1], [:errors, :state], [:error_details, :state], [:errors, :zipcode], [:error_details, :zipcode], [:errors, :jurisdiction], [:error_details, :jurisdiction]]
…idation to use ActiveModel Validations
🎫 Ticket
LG-10760
🛠 Summary of changes
Refactor DocPiiForm to user ActiveModel::Validation helpers that surfaces all validation errors.
📜 Testing Plan
Provide a checklist of steps to confirm the changes.
👀 Screenshots