Class VFilledGroup

java.lang.Object
fc.web.forms.FormValidator
fc.web.forms.VFilledGroup

public final class VFilledGroup extends FormValidator
Validates that a group of fields is filled by the user. By default, every field must be filled. However, optionally it can be specified that every field in the group is not filled (all empty), only 1 field is filled or 1 or more fields (greater than zero) are filled.
  • Constructor Details

    • VFilledGroup

      public VFilledGroup(Form f, String name, String errorMessage, List fields)
      Parameters:
      fields - a non-empty list containting fields to be checked.
    • VFilledGroup

      public VFilledGroup(Form f, String name, String errorMessage, Field[] fields)
      Parameters:
      fields - a non-empty array containting fields to be checked.
  • Method Details

    • onlyOneEmpty

      Calling this method will result in requiring that all fields must be filled except for any one empty field. Calling this method overrides any other methods that were called previously.
    • onlyOneFilled

      Calling this method will result in requiring that all fields be empty except for exactly one filled field (any field). Calling this method overrides any other methods that were called previously.
    • oneOrMoreFilled

      Calling this method will result in requiring that one or more fields by filled (all the fields cannot be empty). Calling this method overrides any other methods that were called previously.
    • allFilledOrEmpty

      This is the default mode. Requires that all fields must be filled. Calling this method overrides any other methods that were called previously.
    • validate

      public boolean validate(FormData fd, jakarta.servlet.http.HttpServletRequest req)
      Description copied from class: FormValidator
      Validates multiple fields together. Note, implementations need not call the validator for each field if that field also has a field level validator (since each field is individually validated by the form). Implementations should validate multiple fields to see if they make sense when analysed as a whole.

      Important notes: Typically, validation should be skipped in the following circumstances:

      • The field is disabled.
      • The field is an instance of DependentField and the
        invalid reference
        DependentField#shouldValidate
        method returns false.
      Specified by:
      validate in class FormValidator
      Returns:
      true is validation succeeded, false otherwise