Package org.bson

Interface FieldNameValidator


public interface FieldNameValidator
A field name validator, for use by BSON writers to validate field names as documents are encoded.
Since:
3.0
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    end()
    End validation of a single document.
    default String
    Return the validation error message for an invalid field
    Gets a new validator to use for the value of the field with the given name.
    default void
    Start validation of a single document.
    boolean
    validate(String fieldName)
    Returns true if the field name is valid, false otherwise.
  • Method Details

    • validate

      boolean validate(String fieldName)
      Returns true if the field name is valid, false otherwise.
      Parameters:
      fieldName - the field name
      Returns:
      true if the field name is valid, false otherwise
    • getValidationErrorMessage

      default String getValidationErrorMessage(String fieldName)
      Return the validation error message for an invalid field
      Parameters:
      fieldName - the field name
      Returns:
      the validation error message
      Throws:
      IllegalArgumentException - if fieldName is actually valid
    • getValidatorForField

      FieldNameValidator getValidatorForField(String fieldName)
      Gets a new validator to use for the value of the field with the given name.
      Parameters:
      fieldName - the field name
      Returns:
      a non-null validator
    • start

      default void start()
      Start validation of a single document.
      Since:
      4.0
    • end

      default void end()
      End validation of a single document.
      Since:
      4.0