Annotation Type LevenshteinDistance


  • @Documented
    @Constraint(validatedBy=LevenshteinDistanceValidator.class)
    @Target({TYPE,ANNOTATION_TYPE})
    @Retention(RUNTIME)
    public @interface LevenshteinDistance
    The annotated bean must contain exact three properties:
    • a field that has to be checked (option field1)
    • a field which entry is compared (option field2)
    • the minimum levenshtein distance both field entries must have (option minDistance)
    • add the error to field1 (option addErrorToField1, default true)
    • add the error to field2 (option addErrorToField2, default true)
    The Levenshtein distance between the entry of fieldCompare and field is calculated, it must be equal or greater then the value of minDistance. not be empty (null or "").
    Supported types are beans, null elements are considered valid.
    Author:
    Valentin Pricop
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      String field1
      field1 name to compare.
      String field2
      field2 name to compare.
      int minDistance
      minimum levenshtein distance.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean addErrorToField1
      add error to field1 (default true).
      boolean addErrorToField2
      add error to field2 (default true).
      Class<?>[] groups
      groups to use.
      String message
      localized message.
      Class<? extends javax.validation.Payload>[] payload
      payload whatever.
    • Element Detail

      • field1

        String field1
        field1 name to compare.
        Returns:
        field/path contains value to compare
      • field2

        String field2
        field2 name to compare.
        Returns:
        field/path contains value to compare
      • minDistance

        int minDistance
        minimum levenshtein distance.
        Returns:
        minimum distance between both entries
      • message

        String message
        localized message.
        Returns:
        localized validation message
        Default:
        "{de.knightsoftnet.validators.shared.LevenshteinDistance.message}"
      • groups

        Class<?>[] groups
        groups to use.
        Returns:
        array of validation groups
        Default:
        {}
      • addErrorToField1

        boolean addErrorToField1
        add error to field1 (default true).
        Returns:
        true if error should be added to field1
        Default:
        true
      • addErrorToField2

        boolean addErrorToField2
        add error to field2 (default true).
        Returns:
        true if error should be added to field2
        Default:
        true
      • payload

        Class<? extends javax.validation.Payload>[] payload
        payload whatever.
        Returns:
        payload class
        Default:
        {}