Refactor validation messages and introduce new parsing and validation…#314
Merged
Conversation
… helpers - Replaced hardcoded validation messages in various validators with constants from ResponseValidationMessages. - Introduced ScriptLinkParsing class with methods for safe parsing of integers, booleans, and DateTime. - Added ScriptLinkValidation class for validating URLs and OpenForm strings. - Consolidated structural mutation messages into StructuralMutationCore. - Updated ArgumentGuards to use new message constants. - Ensured consistency and clarity in error handling across the codebase.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes validation/guard error messages across the Validators and Helpers layers, while adding new shared parsing and format-validation helpers intended to improve consistency in ScriptLink-related input handling.
Changes:
- Centralized several response-validation strings into
ResponseValidationMessagesand updated response validators to use them. - Introduced
ScriptLinkParsing(safe int/bool/DateTime parsing) andScriptLinkValidation(URL/OpenForm validation), plus new unit tests for both. - Consolidated/expanded structural-mutation message constants in
StructuralMutationCoreand updated various helper methods to use the shared message constants.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/RarelySimple.AvatarScriptLink.Objects.Validators/RowObjectResponseValidators.cs | Switched hardcoded RowObject validation strings to centralized constants. |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Validators/ResponseValidationMessages.cs | Added centralized constants for response validation messages. |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Validators/OptionObjectResponseValidators.cs | Switched hardcoded OptionObject validation strings to centralized constants. |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Validators/FormObjectResponseValidators.cs | Switched hardcoded FormObject validation strings to centralized constants. |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Validators/FieldObjectResponseValidators.cs | Switched hardcoded FieldObject validation strings to centralized constants (incl. formatted flag message). |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Helpers/Validators/ArgumentGuards.cs | Refactored/changed accessibility and began reusing shared structural-mutation messages. |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Helpers/StructuralMutationCore.cs | Added additional shared structural-mutation message constants. |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Helpers/ScriptLinkValidation.cs | Added new URL/OpenForm validation helpers. |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Helpers/ScriptLinkParsing.cs | Added new safe parsing helpers for int/bool/DateTime. |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Helpers/OptionObjectHelpers.cs | Updated thrown message references to consolidated structural-mutation messages. |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Helpers/OptionObject2Helpers.cs | Updated thrown message references to consolidated structural-mutation messages. |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Helpers/OptionObject2015Helpers.cs | Updated thrown message references to consolidated structural-mutation messages. |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Helpers/FormObjectHelpers.cs | Updated thrown message references to consolidated structural-mutation messages. |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Helpers.Tests/ScriptLinkValidationTests.cs | Added unit tests for the new ScriptLinkValidation helpers. |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Helpers.Tests/ScriptLinkParsingTests.cs | Added unit tests for the new ScriptLinkParsing helpers. |
| dotnet/RarelySimple.AvatarScriptLink.Objects.Helpers.Tests/ArgumentGuardsTests.cs | Removed tests that directly exercised ArgumentGuards. |
…ldObject; ensure proper error handling for null and missing properties
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Refactor validation messages and introduce new parsing and validation helpers