Skip to content

pmanaktala/restricted-input

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to restriced-input 👋

Version License: Apache License 2.0

A helper dependency that has various constraint annotations for restricted inputs.

Adding Maven Dependency

        <dependency>
            <groupId>com.pmanaktala</groupId>
            <artifactId>restricted-input</artifactId>
            <version>2.0.0</version>
        </dependency>

Current Features

1. Restricted Input

import com.pmanaktala.restrictedinput.annotation.RestrictedInput;

class DTO {
    @RestrictedInput(valuesToRestrict = {"abc"}, regexToMatch = {"^[a-zA-Z]*$"}, exactMatchValues = true)
    private String name;
}

Description :

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 and regexToMatch field is empty. i.e. Validation will always pass

Parameters :

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

2. AlphaNumeric Input

import com.pmanaktala.restrictedinput.annotation.AlphaNumericInput;

class DTO {
    @AlphaNumericInput
    private String otherDetails;
}

Description :

Checks if the input is a valid alphanumeric input of not.

  • If the value is null, the validation will fail.

3. ValidPhone Input

import com.pmanaktala.restrictedinput.annotation.ValidPhone;

class DTO {
    @ValidPhone(region = "IN")
    private String phoneNumber;
}

Description :

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 '()'

Author

👤 Parth Manaktala

Show your support

Give a ⭐️ if this project helped you!

📝 License

This project is Apache License 2.0 licensed.


This README was generated with the help of readme-md-generator

About

A custom annotation based spring boot starter that helps restricting the input of a field in input

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages