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
base: master
Are you sure you want to change the base?
Conversation
* @see Constraint | ||
* @since 0.1.0 | ||
*/ | ||
object IsUUID : Constraint |
There was a problem hiding this comment.
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}$")) } |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 { |
There was a problem hiding this comment.
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)) | ||
} |
There was a problem hiding this comment.
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 can we close this? It has been stale for more than a year and we have a new proposed solution on #61 |
Fixes #
Proposed Changes