Annotation Type Validation


  • @Documented
    @Inherited
    @Retention(RUNTIME)
    @Target(TYPE)
    public @interface Validation
    Defines the document validation logic for a collection.
    Since:
    1.3
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.String value  
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      com.mongodb.client.model.ValidationAction action  
      com.mongodb.client.model.ValidationLevel level  
    • Element Detail

      • value

        java.lang.String value
        Returns:
        the query used to validate documents in a collection. This query is not validated so care must be taken to ensure document field names and types are correct.
        MongoDB documentation
        core/document-validation/
      • level

        com.mongodb.client.model.ValidationLevel level
        Returns:
        how strictly MongoDB should apply the validation rules to existing documents during an insert or update.
        See Also:
        ValidationLevel
        Default:
        com.mongodb.client.model.ValidationLevel.STRICT
      • action

        com.mongodb.client.model.ValidationAction action
        Returns:
        how strictly MongoDB should apply the validation rules to existing documents during an insert or update.
        See Also:
        ValidationAction
        Default:
        com.mongodb.client.model.ValidationAction.ERROR