Skip to content

Conversation

vikhy-aws
Copy link

Description

This PR adds a validation helper function to validate the name fields in a monitor. This helper function is used in Alerting to validate the monitor name and trigger name fields.

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

}

fun isValidName(name: String): Boolean {
fun isValidQueryName(name: String): Boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a short doc comment that explains this function validates the doc level monitor DocLevelQuery name specifically? We use the term "query" in many places, so a quick comment can help prevent confusion.
https://github.com/opensearch-project/common-utils/blob/main/src/main/kotlin/org/opensearch/commons/alerting/model/DocLevelQuery.kt#L16

import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test

class ValidationHelpers {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: Could you rename the test suite and it file to something like ValiationHelpersTests? That will follow the naming pattern we've used for other unit test suites.
https://github.com/opensearch-project/common-utils/blob/main/src/test/kotlin/org/opensearch/commons/alerting/MonitorTests.kt

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.

2 participants