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

Validations for the entity are not run for Lazy targets #26

Closed
robert-bor opened this issue Oct 26, 2017 · 0 comments
Closed

Validations for the entity are not run for Lazy targets #26

robert-bor opened this issue Oct 26, 2017 · 0 comments
Labels

Comments

@robert-bor
Copy link
Contributor

Concerns this code:

if (Lazy.class.isAssignableFrom(parameterType)) {
    ParameterizedType genericType = (ParameterizedType) parameter.getGenericParameterType();
    Type entityType = genericType.getActualTypeArguments()[0];
    return new LazyResolveEntity(form, id, (Class<?>) entityType, annotation);
} else {
    Object mappedTarget = resolveEntity(form, id, parameterType, annotation);
    // Check for @Valid on the mapped target and apply the validation rules to the mapped target
    validateObject(parameter, mavContainer, webRequest, binderFactory, mappedTarget);
    return mappedTarget;
}

The else-clause validateObject call is not execute for the delayed LazyResolve.

@robert-bor robert-bor added the bug label Oct 26, 2017
robert-bor added a commit that referenced this issue Oct 26, 2017
Issue #26. If the @MergedForm maps to a Lazy object, it delays the process of mapping until the time that get() is called on the Lazy object. At that time, it should work exactly the same way as a regular validation run. Forms are always validated right away. However, the final objects are only validated when direct mapping takes place. The process has been refactored so that validation on the final target is included in the delayed mapping process. Note that Lazy.get() must now deal with Exception. The pro of this approach is that it hooks onto the regular binding result handler.
robert-bor added a commit that referenced this issue Oct 26, 2017
Issue #26. If the @MergedForm maps to a Lazy object, it delays the process of mapping until the time that get() is called on the Lazy object. At that time, it should work exactly the same way as a regular validation run. Forms are always validated right away. However, the final objects are only validated when direct mapping takes place. The process has been refactored so that validation on the final target is included in the delayed mapping process. Note that Lazy.get() must now deal with Exception. The pro of this approach is that it hooks onto the regular binding result handler.
robert-bor added a commit that referenced this issue Oct 30, 2017
Issue #26. If the @MergedForm maps to a Lazy object, it delays the process of mapping until the time that get() is called on the Lazy object. At that time, it should work exactly the same way as a regular validation run. Forms are always validated right away. However, the final objects are only validated when direct mapping takes place. The process has been refactored so that validation on the final target is included in the delayed mapping process. Note that Lazy.get() must now deal with Exception. The pro of this approach is that it hooks onto the regular binding result handler.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant