Skip to content

Commit

Permalink
Fix to get regexp properly from the pattern constraint (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kieun authored Sep 25, 2023
1 parent 437d7da commit c631886
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal object ConstraintResolver {

private fun FieldDescriptor.maybeSizeConstraint() = findConstraints(this).firstOrNull { SIZE_CONSTRAINT == it.name }

internal fun maybePattern(fieldDescriptor: FieldDescriptor?) = fieldDescriptor?.maybePatternConstraint()?.let { it.configuration["pattern"] as? String }
internal fun maybePattern(fieldDescriptor: FieldDescriptor?) = fieldDescriptor?.maybePatternConstraint()?.let { it.configuration["regexp"] as? String }

private fun FieldDescriptor.maybePatternConstraint() = findConstraints(this).firstOrNull { PATTERN_CONSTRAINT == it.name }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ class JsonSchemaFromFieldDescriptorsGeneratorTest {
listOf(
Constraint(
"javax.validation.constraints.Pattern",
mapOf("pattern" to "[a-z]")
mapOf("regexp" to "[a-z]")
)
)
)
Expand Down

0 comments on commit c631886

Please sign in to comment.