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 field content structs #7

Merged
merged 2 commits into from
Sep 16, 2024
Merged

add field content structs #7

merged 2 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.

- also update .formatter.exs to include import_deps for typed_struct
This commit adds tests for the `FieldContent` struct and the `validate_attributed_value` function in the `Validators` module. The tests cover creating a new `FieldContent` struct with different types of attributed values, including strings, numbers, `DateTime`, and `Date`. It also tests for raising an `ArgumentError` when an invalid attributed value type is provided. Additionally, it tests for raising an `ArgumentError` when an attributed value contains unsupported HTML tags.
@njausteve njausteve merged commit ab73ef4 into main Sep 16, 2024
5 checks passed
@njausteve njausteve deleted the add-field-content-structs branch September 16, 2024 04:55
@njausteve njausteve restored the add-field-content-structs branch September 22, 2024 13:55
@njausteve njausteve deleted the add-field-content-structs branch September 22, 2024 13:55
@njausteve
Copy link
Owner Author

closed: #145

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant