Skip to content

Conversation

mary-prince
Copy link
Contributor

Added settings that contain provided custom format for validations.

Copy link
Collaborator

@potocpav potocpav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • We also need to fix normalizeString to use the return value of the format parsing function.
  • Could you add a form example form using the customFormats setting?

-}
type alias Settings =
{ customFormats : Dict String (String -> Result String String)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, returning an error may be an overkill. Perhaps return Result () String?

|> Maybe.map (\validation -> validation value)
|> Maybe.withDefault (Result.Ok value)
in
Result.mapError (\err -> error (Error.InvalidCustomFormat err)) customValidation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be good to report customFormat, not err, in Error.InvalidCustomFormat. Our front-end may want to show a hint corresponding to which Personal number was requested (similar to what ID Check does):

Image
Suggested change
Result.mapError (\err -> error (Error.InvalidCustomFormat err)) customValidation
Result.mapError (\_ -> error (Error.InvalidCustomFormat customFormat)) customValidation

"not the correct format"

InvalidCustomFormat _ ->
"not the correct format"
Copy link
Contributor Author

@mary-prince mary-prince Sep 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@potocpav Shall we by the way give more information here regarding which format it is (which we underscore now) or leave is same as InvalidFormat?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should. The format string is internal, and should not be present in the UI. If users want to see more info, they need to implement their own view.

@mary-prince mary-prince merged commit b03ea8e into main Sep 8, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants