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

added new validation if property is UUID #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eutiagocosta
Copy link

Fixes #

Proposed Changes

  • Created new validation if property is UUID
  • Added custom messages for i18n

* @see Constraint
* @since 0.1.0
*/
object IsUUID : Constraint
Copy link
Member

Choose a reason for hiding this comment

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

This constraint must be applied only for String properties, so it should be moved to the file TextConstraints.kt. BTW, I think UUID is a better name.

* @return the same receiver property
*/
fun <E> Validator<E>.Property<String?>.isUUID(): Validator<E>.Property<String?> =
this.validate(IsUUID) { it == null || it.matches(Regex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$")) }
Copy link
Member

Choose a reason for hiding this comment

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

This function must be moved to the file StringFunctions.kt.

@@ -6,6 +6,7 @@ org.valiktor.constraints.NotEquals.message=Must not be equal to {value}
org.valiktor.constraints.In.message=Must be in {values}
org.valiktor.constraints.NotIn.message=Must not be in {values}
org.valiktor.constraints.Valid.message=Must be valid
org.valiktor.constraints.IsUUID.message=Not a valid identifier (uuid)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
org.valiktor.constraints.IsUUID.message=Not a valid identifier (uuid)
org.valiktor.constraints.UUID.message=Must be a valid UUID

@@ -6,6 +6,7 @@ org.valiktor.constraints.NotEquals.message=No pot ser igual a {value}
org.valiktor.constraints.In.message=Ha de ser un dels seg\u00FCents: {values}
org.valiktor.constraints.NotIn.message=No pot ser un dels seg\u00FCents: {values}
org.valiktor.constraints.Valid.message=Ha de ser v\u00E0lid
org.valiktor.constraints.IsUUID.message=No \u00E9s un identificador v\u00E0lid (uuid)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
org.valiktor.constraints.IsUUID.message=No \u00E9s un identificador v\u00E0lid (uuid)
org.valiktor.constraints.UUID.message=Ha de ser un UUID vàlid

@@ -6,6 +6,7 @@ org.valiktor.constraints.NotEquals.message=Must not be equal to {value}
org.valiktor.constraints.In.message=Must be in {values}
org.valiktor.constraints.NotIn.message=Must not be in {values}
org.valiktor.constraints.Valid.message=Must be valid
org.valiktor.constraints.IsUUID.message=Not a valid identifier (uuid)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
org.valiktor.constraints.IsUUID.message=Not a valid identifier (uuid)
org.valiktor.constraints.UUID.message=Must be a valid UUID

@@ -6,6 +6,7 @@ org.valiktor.constraints.NotEquals.message=Darf nicht gleich {value} sein
org.valiktor.constraints.In.message=Muss in {values} sein
org.valiktor.constraints.NotIn.message=Darf nicht in {values} sein
org.valiktor.constraints.Valid.message=Muss g\u00FCltig sein
org.valiktor.constraints.IsUUID.message=Kein g\u00FCltiger Bezeichner (uuid)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
org.valiktor.constraints.IsUUID.message=Kein g\u00FCltiger Bezeichner (uuid)
org.valiktor.constraints.UUID.message=Muss eine gültige UUID sein

@@ -6,6 +6,7 @@ org.valiktor.constraints.NotEquals.message=No puede ser igual a {value}
org.valiktor.constraints.In.message=Tiene que ser uno de eses: {values}
org.valiktor.constraints.NotIn.message=No puede ser uno de eses: {values}
org.valiktor.constraints.Valid.message=Tiene que ser v\u00E1lido
org.valiktor.constraints.IsUUID.message=No es un identificador v\u00E1lido (uuid)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
org.valiktor.constraints.IsUUID.message=No es un identificador v\u00E1lido (uuid)
org.valiktor.constraints.UUID.message=Tiene que ser uno UUID válido

@@ -6,6 +6,7 @@ org.valiktor.constraints.NotEquals.message=N\u00E3o deve ser igual a {value}
org.valiktor.constraints.In.message=Deve ser um desses: {values}
org.valiktor.constraints.NotIn.message=N\u00E3o deve ser um desses: {values}
org.valiktor.constraints.Valid.message=Deve ser v\u00E1lido
org.valiktor.constraints.IsUUID.message=N\u00E3o \u00E9 um identificador \u0028uuid\u0029 v\u00E1lido
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
org.valiktor.constraints.IsUUID.message=N\u00E3o \u00E9 um identificador \u0028uuid\u0029 v\u00E1lido
org.valiktor.constraints.UUID.message=Deve ser um UUID válido

@@ -119,3 +119,17 @@ class ValidTest {
entry(SupportedLocales.PT_BR, "Deve ser válido"))
}
}

class IsUUIDTest {
Copy link
Member

Choose a reason for hiding this comment

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

It must be moved to TextConstraintsTest.kt

property = "id",
value = "a3551f72",
constraint = IsUUID))
}
Copy link
Member

Choose a reason for hiding this comment

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

It should be moved to StringFunctionsTest.kt

@rodolphocouto rodolphocouto added this to the 0.10.0 milestone Feb 8, 2020
@rodolphocouto rodolphocouto added the feature New feature or request label Mar 30, 2020
@rodolphocouto rodolphocouto modified the milestones: 0.10.0, 0.11.0, 0.12.0 Mar 30, 2020
@rodolphocouto rodolphocouto modified the milestones: 0.12.0, 0.13.0 Jun 28, 2020
@gabrielerzinger
Copy link

@rodolphocouto can we close this? It has been stale for more than a year and we have a new proposed solution on #61

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Development

Successfully merging this pull request may close these issues.

None yet

3 participants