Package org.kiwiproject.validation
Annotation Interface FilePath
@Documented
@Constraint(validatedBy={})
@Target({METHOD,FIELD,ANNOTATION_TYPE,CONSTRUCTOR,PARAMETER,TYPE_USE})
@Retention(RUNTIME)
public @interface FilePath
The annotated element must point to an existing file. Please read the implementation note regarding
intended usage of this annotation with respect to the potential for
Path Traversal attacks.
By default, does not permit null values. If the element being validated allows null values, you can
set allowNull() to true.
Examples:
@FilePath private String location;
@FilePath(allowNull = true)
public String getLocation() { return this.location; }
- Implementation Note:
- This annotation is not intended to validate user input from client-side applications, because of the possibility of Path Traversal attacks. Instead, the intended usage is to validate application configuration parameters, e.g. an application reads a local configuration file at startup. Even this is not 100% safe, since the configuration could come from a remote location such as a configuration service, so users should understand the usage risks and mitigate when possible.
-
Optional Element Summary
Optional Elements
-
Element Details
-
message
String message- Default:
- "{org.kiwiproject.validation.FilePath.message}"
-
groups
Class<?>[] groups- Default:
- {}
-
payload
Class<? extends jakarta.validation.Payload>[] payload- Default:
- {}
-
allowNull
boolean allowNullWhether to consider null as valid. The default is false.- Returns:
- true to consider null as valid
- Default:
- false
-