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

Check values in arrays #835

Merged
merged 2 commits into from
May 30, 2022
Merged

Check values in arrays #835

merged 2 commits into from
May 30, 2022

Conversation

jsoriano
Copy link
Member

Add validation for all values in arrays.

This is needed when some validation of the values is desired, apart of type validation. This is the case with IPs (elastic/integrations#3408) or event types (#615 (comment)).

This change was part of #771, but this is being delayed due to elastic/integrations#3016.

Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

A more generic non-blocking comment - it's really easy to get lost in the logic due to multiple switch-cases and "if" clauses. Maybe you should drop a few comments to show field examples including edge cases.

@elasticmachine
Copy link
Collaborator

elasticmachine commented May 30, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-05-30T11:08:33.938+0000

  • Duration: 32 min 5 sec

Test stats 🧪

Test Results
Failed 0
Passed 720
Skipped 0
Total 720

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@elasticmachine
Copy link
Collaborator

elasticmachine commented May 30, 2022

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (30/30) 💚
Files 64.22% (70/109) 👍
Classes 58.278% (88/151) 👍
Methods 47.421% (285/601) 👍 0.088
Lines 32.348% (2616/8087) 👎
Conditionals 100.0% (0/0) 💚

@jsoriano
Copy link
Member Author

A more generic non-blocking comment - it's really easy to get lost in the logic due to multiple switch-cases and "if" clauses. Maybe you should drop a few comments to show field examples including edge cases.

I have added comments, and refactored the code to explicitly return type errors instead of having the if valid condition at the end. I have also moved the code to a function for single values, what reduces the nesting level of the main code.

@mtojek let me know what you think.

@jsoriano jsoriano requested a review from mtojek May 30, 2022 11:12
Copy link
Contributor

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

Thank you! That's exactly what I meant.

@jsoriano jsoriano merged commit 9211c19 into elastic:main May 30, 2022
@jsoriano jsoriano deleted the check-array-values branch May 30, 2022 12:36
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.

3 participants