Our project has a feature to store invalidated document to DB for later usage. We would have an endpoint for that. All the other places we would keep default behavior (full validation).
One possible solution is we provide custom persister implementation for DocumentationPersister as stated at GetA12 Login.
public interface DocumentPersister {
boolean isSupported(IDocument document);
DataServicesDocument create(IDocument document, Locale locale);
DataServicesDocument delete(DataServicesDocument document);
DataServicesDocument update(DocumentReference documentReference, IDocument newDocument, Locale locale);
}
The problem is AbstractDocumentPersister has some private methods: persistAction (and its overloaded), syncAttachments ā We can copy the implementation but that would leads to uncertainty when come to maintaining, update A12 version.
Iām asking whether you have any idea for this problem.
Thanks.
hi @luu-far-shell , after some consultations with data-services team a possible solution for that problem is by creating a new model that will be subtype of the parent and enable validation only on that subtype model. Keyword here is heterogeneity.
Hi,
we want to preset values in a document and persist it in the database. To save it in database we would need to skip the validation phase. Is heterogeneity still the recommended way or is there an otherway to save a document without validation?
Hi @christoph-wintry-light ,
There is an A12 ticket A12-16873 that is focusing on this use-case where the validation strategy is passed to the DocumentService by the caller. I believe this would solve your problem. In the meantime, you can use mgmtp.a12.dataservices.documents.validation.skipForModels configuration key to skip validation for all documents of a certain model. You can decide in event listener for DocumentBeforeUpdateEvent and for DocumentBeforeCreateEvent when to execute validation based on the state of your document or system.
This answer is valid for DS version 37.2. - 36.3
Hi @christoph-wintry-light,
the A12 ticket to allow passing a validation strategy to DocumentService (A12-16873) has been completed and will be released with 2025.06-ext2.