A helper dependency that has various constraint annotations for restricted inputs.
<dependency>
<groupId>com.pmanaktala</groupId>
<artifactId>restricted-input</artifactId>
<version>2.0.0</version>
</dependency>
import com.pmanaktala.restrictedinput.annotation.RestrictedInput;
class DTO {
@RestrictedInput(valuesToRestrict = {"abc"}, regexToMatch = {"^[a-zA-Z]*$"}, exactMatchValues = true)
private String name;
}
Checks if the input satisfies the given conditions.
- All the conditions specified should match.
- If the value is null, the validation will pass.
- By default,
valuesToRestrict
field andregexToMatch
field is empty. i.e. Validation will always pass
Field | Mandatory | Description | Default Value | Comments |
---|---|---|---|---|
valuesToRestrict | No | Contains a list of values that are not allowed | No value | NA |
regexToMatch | No | Contains a list of regular expression that should match. | No value | Note : All the regex should match else the validation should fail. |
exactMatchValues | No | If the values in parameter 1, should exactly match or not. | false | NA |
import com.pmanaktala.restrictedinput.annotation.AlphaNumericInput;
class DTO {
@AlphaNumericInput
private String otherDetails;
}
Checks if the input is a valid alphanumeric input of not.
- If the value is null, the validation will fail.
import com.pmanaktala.restrictedinput.annotation.ValidPhone;
class DTO {
@ValidPhone(region = "IN")
private String phoneNumber;
}
Checks if the input is a valid phone number input of not.
- The datatype of the input is set to be string, as it can contain symbols such as '+' and '()'
👤 Parth Manaktala
- Website: https://pmanaktala.com
- Github: @pmanaktala
Give a ⭐️ if this project helped you!
This project is Apache License 2.0 licensed.
This README was generated with the help of readme-md-generator