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

Support for javax/jakarta.validation in entity views #1866

Open
kuhnroyal opened this issue Feb 1, 2024 · 4 comments
Open

Support for javax/jakarta.validation in entity views #1866

kuhnroyal opened this issue Feb 1, 2024 · 4 comments

Comments

@kuhnroyal
Copy link

Hello,

I am looking for a way to enable entity validation for entity view classes when used with Spring Data JPA.
Not sure if I missed something but I can't find a way to get blaze repositories to validate the entities.

Is this supported?

@beikov
Copy link
Member

beikov commented Feb 1, 2024

Hi, can you please share more details? Usually, there are two types of validation:

  • Validation on persistence (Hibernate configuration)
  • Validation on request (Spring MVC)

Please show the repositories you are using as well as the invoking code and share the exact expectations.

@beikov beikov added the question label Feb 1, 2024
@kuhnroyal
Copy link
Author

I am talking about validation on persistence. Validation of request bodies is working as expected.

So in this case the email validation works fine as request validation but not when saving a view.

@EntityView(User::class)
@CreatableEntityView
interface InviteUserView {
    @get:IdMapping
    val id: UUID

    @get:Email
    var email: String
}

@Transactional
interface InviteUserViewRepository : EntityViewRepository<InviteUserView, UUID> {
    fun save(user: InviteUserView): InviteUserView
}

@Service
class SomeUserService @Autowired constructor(
	private val repository: InviteUserViewRepository,
) {
	fun saveUser(user: InviteUserView):  InviteUserView {
		return repository.save(user)
    }
}

The repositories are scanned via @EnableBlazeRepositories("....").

@beikov
Copy link
Member

beikov commented Feb 5, 2024

Ok, so validation of creatable/updatable entity views is currently not automatically done when an object is passed to some save method. I'll mark this as feature request then.

@kuhnroyal
Copy link
Author

Ok, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants