Skip to content
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

Add FieldContent Struct with Validation and Update TypedStruct Dependency #8

Merged
merged 3 commits into from
Sep 16, 2024

Conversation

njausteve
Copy link
Owner

@njausteve njausteve commented Sep 16, 2024

Title

Add FieldContent Struct with Validation and Update TypedStruct Dependency

Type of Change

  • New feature

Description

This pull request adds the typed_struct dependency and introduces the FieldContent struct, which represents a field on a pass. The struct supports attributed values, including optional HTML markup for more dynamic content presentation. A Validators module is added to ensure that attributed values are properly validated, including checks for unsupported HTML tags. Tests are provided to verify struct creation and validation behaviors.

Testing

Tests have been added for:

  • Creation of FieldContent structs with different types of attributed values (string, number, DateTime, and Date).
  • Validation logic that raises ArgumentError for unsupported types or invalid HTML markup.

Impact

  • New Dependency: The project now relies on typed_struct for defining typed structs with defaults.
  • Performance: Minor performance overhead due to the added validation logic.
  • Security: Improved security with validation for attributed values, particularly with handling HTML content.

Additional Information

No known breaking changes, but reviewers should focus on the HTML validation logic in the Validators module.

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.

- typed_struct is unmaintained but typedstruct is
This commit adds a JSON encoding implementation for the `FieldContent` struct in the `ExPass.Structs.FieldContent` module. The `encode/2` function converts a `FieldContent` struct into a JSON representation by filtering out `nil` values, converting keys to camelCase format using the `ExPass.Utils.Converter.camelize_key/1` function, and encoding the resulting map using Jason. This encoding functionality allows for consistent and standardized representation of `FieldContent` structs when interacting with external systems or APIs.
@njausteve njausteve merged commit 58ab31f into main Sep 16, 2024
5 checks passed
@njausteve njausteve deleted the switch-to-typedstruct branch September 16, 2024 11:08
@njausteve njausteve changed the title y Add FieldContent Struct with Validation and Update TypedStruct Dependency Sep 16, 2024
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.

1 participant