Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ flapdoodleVersion=4.33.0
mongoJavaServerVersion=1.47.0
commonsValidatorVersion=1.10.1
concurrentlinkedhashmapLruVersion=1.4.2
defaultElImplementationVersion=5.0.0
# See https://projects.eclipse.org/releases/jakarta-10 and latest 5.0.x from https://mvnrepository.com/artifact/jakarta.el/jakarta.el-api
elApiVersion=5.0.1
# Hibernate Validator 9 uses Jakarta EL 6; Expressly 6.0.0 depends on EL API 6.0.1.
defaultElImplementationVersion=6.0.0
elApiVersion=6.0.1
expectitCoreVersion=0.9.0
geantyrefVersion=1.3.16
gparsVersion=1.2.1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.grails.datastore.gorm.validation.jakarta

import jakarta.validation.Validation
import jakarta.validation.constraints.DecimalMax
import jakarta.validation.constraints.DecimalMin
import org.hibernate.validator.HibernateValidator
import spock.lang.Specification
import spock.lang.Unroll

class BeanValidationMessageInterpolationSpec extends Specification {

@Unroll
void 'interpolates the standard decimal-bound message for #propertyName'() {
given:
def factory = Validation.byProvider(HibernateValidator).configure()
.defaultLocale(Locale.ENGLISH).buildValidatorFactory()
def amount = new Amount((propertyName): value)

when:
def violations = factory.validator.validate(amount)

then:
violations.size() == 1
violations.first().propertyPath.toString() == propertyName
violations.first().message == message

cleanup:
factory?.close()

where:
propertyName | value || message
'minimum' | 1.0G || 'must be greater than or equal to 1.5'
'exclusiveMinimum' | 1.5G || 'must be greater than 1.5'
'maximum' | 5.0G || 'must be less than or equal to 4.5'
'exclusiveMaximum' | 4.5G || 'must be less than 4.5'
}

static class Amount {

@DecimalMin('1.5')
BigDecimal minimum

@DecimalMin(value = '1.5', inclusive = false)
BigDecimal exclusiveMinimum

@DecimalMax('4.5')
BigDecimal maximum

@DecimalMax(value = '4.5', inclusive = false)
BigDecimal exclusiveMaximum
}
}
10 changes: 10 additions & 0 deletions grails-doc/src/en/guide/upgrading/upgrading90x.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1635,3 +1635,13 @@ Where there is no `grailsCacheManager`, as with `grails.cache.enabled: false`, t
* To keep the cache annotations caching with a cache manager of the application's own, name it `grailsCacheManager`, or register `grailsCacheManager` as its alias. Declaring `@Qualifier("grailsCacheManager")` on its `@Bean` method or its class is not enough: the annotations take no cache manager by that qualifier, only by the name or the alias. With caching enabled that replaces the plugin's, which a cache provider plugin does too; it must then implement `GrailsCacheManager`, as the plugin's startup hook requires. For example, a subclass of Spring's `JCacheCacheManager` can implement `cacheExists` and `destroyCache`.
* A `grailsCacheManager` cannot be created from a bean with cached methods, as that bean is given `grailsCacheManager` while it is created; the context does not start. Create it from the dependencies of that bean instead.
* A plugin compiled against Grails 8 keeps the Grails 8.0.1 behaviour for its cached classes until it is compiled against Grails 9.

==== 34. Jakarta Expression Language 6 for Bean Validation

GORM's default Expression Language implementation is Expressly 6.0.0, with Jakarta EL API 6.0.1, matching the EL 6
API that Hibernate Validator 9 uses. This fixes message interpolation in standalone validation: reporting a standard
`@DecimalMin` or `@DecimalMax` violation could previously throw `NoClassDefFoundError` for
`jakarta.el.RecordELResolver` instead of returning the constraint violation and its message.

If the application replaces GORM's default EL implementation, supply an EL 6-compatible implementation and remove
explicit EL 5 version overrides. Applications using the default dependencies need no code changes.
Loading