Merged
Conversation
mbier
approved these changes
Jul 18, 2025
leocavalcante
approved these changes
Jul 18, 2025
apiovani
approved these changes
Jul 18, 2025
fabriciogpp
approved these changes
Jul 18, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces support for the "nin" (not in) validation rule to ValidGen, which ensures that a field's value is not among a specified set of values. This complements the existing "in" validation rule by providing the inverse functionality.
- Adds "nin" validation rule support with proper parsing, code generation, and error handling
- Updates validation logic to use appropriate concatenation operators ("&&" for "nin", "||" for "in")
- Includes comprehensive test coverage for the new validation rule
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates documentation to mark "nin" validation as implemented for string types |
| validgen/parser_validation.go | Adds "nin" to the list of supported validations that accept multiple values |
| validgen/test_elements.go | Introduces NotInOp constant, adds "nin" mapping, and implements concatenation operator logic |
| validgen/if_code.go | Updates condition generation to use dynamic concatenation operators |
| validgen/if_code_test.go | Adds test case for "nin" validation code generation |
| validgen/get_test_elements_string_test.go | Updates existing tests and adds new test for "nin" validation |
| tests/endtoend/string.go | Adds test struct field and validation scenarios for "nin" rule |
| tests/endtoend/stringtype_validator.go | Contains generated validation code for the new "nin" field |
Comments suppressed due to low confidence (1)
validgen/test_elements.go:28
- The validation logic for missing concat operator should be moved to the GetTestElements function where the concatOperator is set, rather than in IfCode. This would provide earlier error detection and better separation of concerns.
loperand string
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.
Closes #18
This PR introduces support for the "nin" (not in) validation rule, which ensures that a field's value is not among a specified set of values. The changes include updates to validation logic, test cases, and documentation to accommodate this new feature.
Feature Addition: "nin" Validation Rule
README.mdto document the "nin" validation rule, specifying its supported types and usage. ([README.mdL67-R67](https://github.com/opencodeco/validgen/pull/27/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L67-R67))ninvalidation rule to theParserValidationfunction invalidgen/parser_validation.go, allowing it to parse "nin" rules. ([validgen/parser_validation.goR37](https://github.com/opencodeco/validgen/pull/27/files#diff-624caa67bdb0ba682f775f0fa90bbfa9ff8df232412316dd08381274997123b6R37))NotInOpconstant invalidgen/test_elements.goand updated theGetTestElementsfunction to handle "nin" validations, including setting the appropriate concatenation operator (&&). ([[1]](https://github.com/opencodeco/validgen/pull/27/files#diff-d28674cf641191cff72b6b261ebd77c638dca5b9477702dd1475d7e6f77468cbL11-R21),[[2]](https://github.com/opencodeco/validgen/pull/27/files#diff-d28674cf641191cff72b6b261ebd77c638dca5b9477702dd1475d7e6f77468cbR47),[[3]](https://github.com/opencodeco/validgen/pull/27/files#diff-d28674cf641191cff72b6b261ebd77c638dca5b9477702dd1475d7e6f77468cbL56-R60),[[4]](https://github.com/opencodeco/validgen/pull/27/files#diff-d28674cf641191cff72b6b261ebd77c638dca5b9477702dd1475d7e6f77468cbR83-R92),[[5]](https://github.com/opencodeco/validgen/pull/27/files#diff-d28674cf641191cff72b6b261ebd77c638dca5b9477702dd1475d7e6f77468cbR102))Test Enhancements
tests/endtoend/string.goto validate the behavior of the "nin" rule, including scenarios where the validation passes and fails. ([[1]](https://github.com/opencodeco/validgen/pull/27/files#diff-4f0802d7c2e573b0e4aaa631328677086e14b794beeb22c7fa1219a7bb92c4cbR14),[[2]](https://github.com/opencodeco/validgen/pull/27/files#diff-4f0802d7c2e573b0e4aaa631328677086e14b794beeb22c7fa1219a7bb92c4cbR29),[[3]](https://github.com/opencodeco/validgen/pull/27/files#diff-4f0802d7c2e573b0e4aaa631328677086e14b794beeb22c7fa1219a7bb92c4cbR40),[[4]](https://github.com/opencodeco/validgen/pull/27/files#diff-4f0802d7c2e573b0e4aaa631328677086e14b794beeb22c7fa1219a7bb92c4cbR56))TestGetTestElementsWithStringFieldsfunction invalidgen/get_test_elements_string_test.goto include a test case for "nin" validation with string fields. ([[1]](https://github.com/opencodeco/validgen/pull/27/files#diff-3b9d1a12858980987436bb3f555f8f3861f65a83e810b28aaffda521dc11c071R132),[[2]](https://github.com/opencodeco/validgen/pull/27/files#diff-3b9d1a12858980987436bb3f555f8f3861f65a83e810b28aaffda521dc11c071R146-R163))IfCodefunction invalidgen/if_code_test.goto verify the generated code for "nin" validations. ([validgen/if_code_test.goR54-R66](https://github.com/opencodeco/validgen/pull/27/files#diff-871326416a200a07b2b5ef890daed108971c94f739c84d93d27975fda2643ee4R54-R66))Validation Logic Updates
StringTypeValidatefunction intests/endtoend/stringtype_validator.goto include validation logic for the "nin" rule, ensuring that the value is not in the specified set. ([tests/endtoend/stringtype_validator.goR48-R51](https://github.com/opencodeco/validgen/pull/27/files#diff-1d142222f7677210e08405f7a33515144de5511e39890fe4a562583328b24724R48-R51))IfCodefunction invalidgen/if_code.goto use the appropriate concatenation operator (&&for "nin"). ([validgen/if_code.goL31-R31](https://github.com/opencodeco/validgen/pull/27/files#diff-2f7f06c49877e879996207790c5bd1f998c9511e51b9ab2cecf77ade0a445f24L31-R31))