Package com.example.blogs.app.validation
Annotation Interface AtLeastOneField
@Documented
@Constraint(validatedBy=AtLeastOneFieldValidator.class)
@Target(TYPE)
@Retention(RUNTIME)
public @interface AtLeastOneField
Validates that at least one of the specified fields has a non-blank value.
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<?>[]Validation groups to which this constraint belongs.The validation error message to display when none of the specified fields have values.Class<? extends jakarta.validation.Payload>[]Payload for clients to assign custom metadata to this constraint.
-
Element Details
-
message
String messageThe validation error message to display when none of the specified fields have values.- Returns:
- the error message
- Default:
"At least one field must be provided"
-
groups
Class<?>[] groupsValidation groups to which this constraint belongs.- Returns:
- the validation groups
- Default:
{}
-
payload
Class<? extends jakarta.validation.Payload>[] payloadPayload for clients to assign custom metadata to this constraint.- Returns:
- the payload
- Default:
{}
-
fields
String[] fieldsThe names of the fields to validate for at least one non-blank value.- Returns:
- the field names to check
-