Skip to content

Commit

Permalink
Add custom validation message for array constraints (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiyanwso2 authored Nov 28, 2024
1 parent fb2ff98 commit 6af90f2
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,17 @@ public type $util.resolveSpecialCharacters($resourceName) record {|
#if( $element.isArray() && ($element.getMin() == $min || $element.getMax() == $max) )
@constraint:Array {
#if( $element.getMin() == $min )
minLength: $min#if( $element.getMax() == $max )$separator#end
minLength: {
value: $min$separator
message: "This field must be an array containing at least one item."
}#if( $element.getMax() == $max )$separator#end
#end

#if( $element.getMax() == $max )
maxLength: $max
maxLength: {
value: $max$separator
message: "This field must be an array containing at most one item."
}
#end
}
#end
Expand Down Expand Up @@ -155,11 +161,17 @@ public type $util.resolveSpecialCharacters($extendedElement.getTypeName()) recor
#if( $childElement.isArray() && ($childElement.getMin() == $min || $childElement.getMax() == $max) )
@constraint:Array {
#if( $childElement.getMin() == $min )
minLength: $min#if( $childElement.getMax() == $max )$separator#end
minLength: {
value: $min$separator
message: "This field must be an array containing at least one item."
}#if( $childElement.getMax() == $max )$separator#end
#end

#if( $childElement.getMax() == $max )
maxLength: $max
maxLength: {
value: $max$separator
message: "This field must be an array containing at most one item."
}
#end
}
#end
Expand Down

0 comments on commit 6af90f2

Please sign in to comment.