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

String format validator #775

Merged
merged 3 commits into from
Jul 31, 2023

Conversation

TristonianJones
Copy link
Collaborator

@TristonianJones TristonianJones commented Jul 12, 2023

Shift string format validation into the ext.Strings() library.

This change also removes all references to the string format extensions within
the cel and interpreter packages, and shifts validation from an InterpretableDecorator
to an cel.ASTValidator which is applied immediately after type-checking.

Note to reviewers: the majority of the changes are present in the ext/formatting.go
file, and contained within the stringFormatValidator. There are some subtle differences
such as the new validator checks by function name only, and not by overload id (this
will be addressed in a future PR), and the argument length check applies to the original
call signature (size 1) rather than the internal call signature which includes the call
target as the first argument (size 2). Most of the rest of the code is quite similar
to what existed beforehand.

Closes #638

@TristonianJones TristonianJones force-pushed the string-format-validate branch from 1989e9d to 3dc15dc Compare July 12, 2023 06:37
@TristonianJones TristonianJones marked this pull request as ready for review July 12, 2023 06:39
@TristonianJones
Copy link
Collaborator Author

@DangerOnTheRanger would you mind taking a look to see if this matches your expectations?

@TristonianJones TristonianJones requested a review from jpbetz July 17, 2023 15:59
@TristonianJones TristonianJones force-pushed the string-format-validate branch from 3dc15dc to 0e1d73d Compare July 18, 2023 17:42
Copy link
Contributor

@DangerOnTheRanger DangerOnTheRanger left a comment

Choose a reason for hiding this comment

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

Just had a couple small comments, nothing major or anything - LGTM otherwise.

ext/strings_test.go Outdated Show resolved Hide resolved
ext/strings_test.go Show resolved Hide resolved
ext/formatting.go Show resolved Hide resolved
Copy link
Collaborator

@jpbetz jpbetz left a comment

Choose a reason for hiding this comment

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

The way the options are configured (enabled by default) LGTM.

I'll defer to @DangerOnTheRanger on any specifics of the formatting code.

@TristonianJones TristonianJones force-pushed the string-format-validate branch from 2703956 to 77f4dd4 Compare July 19, 2023 19:39
@TristonianJones TristonianJones requested a review from jcking July 19, 2023 19:40
@DangerOnTheRanger
Copy link
Contributor

LGTM

@TristonianJones TristonianJones merged commit 965e9c8 into google:master Jul 31, 2023
@TristonianJones TristonianJones deleted the string-format-validate branch July 31, 2023 17:19
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.

String formatting
4 participants