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

Introduce Newtype instead of AnyVal #14

Merged
merged 11 commits into from
Dec 2, 2022

Conversation

markaya
Copy link
Contributor

@markaya markaya commented Nov 30, 2022

No description provided.

@markaya markaya force-pushed the introduce-Newtype-instead-of-AnyVal branch 3 times, most recently from 9dd4f66 to ec24204 Compare December 1, 2022 12:26
Copy link
Member

@drmarjanovic drmarjanovic left a comment

Choose a reason for hiding this comment

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

I would expose all errors. Not fail on the first of them. We can combine those errors with ++.

"com.softwaremill.sttp.client3" %% "zio" % "3.8.3",
"com.softwaremill.sttp.client3" %% "zio-json" % "3.8.3"
"com.softwaremill.sttp.client3" %% "zio-json" % "3.8.3",
"org.apache.commons" % "commons-lang3" % "3.12.0"
Copy link
Member

Choose a reason for hiding this comment

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

I prefer sorting those by alphabet. So, you can order all of those that way.


package object elasticsearch {
object Routing extends Newtype[String] {
override def assertion = assert { // scalafix:ok
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to use assert(!isEmptyString)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

| - Cannot be longer than 255 bytes (note it is bytes, so multi-byte characters will count towards the 255 limit faster).
| - Names starting with . are deprecated, except for hidden indices and internal indices managed by plugins.
|""".stripMargin
}
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to add a new line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

override def assertion = assertCustom { (name: String) => // scalafix:ok
if (validateIndexName(name)) Left(failure(IndexNameRequirements)) else Right(())
}
private def validateIndexName(name: String): Boolean =
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to add a new line before?

Copy link
Member

Choose a reason for hiding this comment

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

Also, I would rename it to validate. It should be clear that is IndexName.

drmarjanovic
drmarjanovic previously approved these changes Dec 2, 2022
@markaya markaya force-pushed the introduce-Newtype-instead-of-AnyVal branch from f9a65ed to b62728f Compare December 2, 2022 12:49
@drmarjanovic drmarjanovic merged commit 5221b76 into main Dec 2, 2022
@drmarjanovic drmarjanovic deleted the introduce-Newtype-instead-of-AnyVal branch December 2, 2022 12:54
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.

2 participants