Package org.projectnessie.model
Class Validation
- java.lang.Object
-
- org.projectnessie.model.Validation
-
public final class Validation extends Object
Collection of validation rules.
-
-
Field Summary
Fields Modifier and Type Field Description static StringHASH_MESSAGEstatic PatternHASH_PATTERNstatic StringHASH_REGEXstatic Collection<String>INVALID_REPO_IDSInvalid owner/repo names that represent current and reserved URI path elements.static StringOWNER_MESSAGEstatic PatternOWNER_PATTERNstatic StringOWNER_REGEXstatic StringREF_NAME_MESSAGEstatic StringREF_NAME_OR_HASH_MESSAGEstatic PatternREF_NAME_OR_HASH_PATTERNstatic StringREF_NAME_OR_HASH_REGEXstatic PatternREF_NAME_PATTERNstatic StringREF_NAME_REGEXstatic StringREPO_MESSAGEstatic PatternREPO_PATTERNstatic StringREPO_REGEX
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisValidHash(String hash)Just checks whether a string is a valid hash, but doesn't throw an exception.static booleanisValidOwner(String repoOwner)Just checks whether a string is a valid repository owner, but doesn't throw an exception.static booleanisValidReferenceName(String referenceName)Just checks whether a string is a valid reference-name, but doesn't throw an exception.static booleanisValidReferenceNameOrHash(String ref)Just checks whether a string is a valid reference-name (as perisValidReferenceName(String)) or a valid hash (as perisValidHash(String)).static booleanisValidRepo(String repo)Just checks whether a string is a valid repository ID, but doesn't throw an exception.static StringvalidateHash(String referenceName)Validates whether a string is a valid hash.static StringvalidateOwner(String owner)Validates whether a string is a valid repository ID.static StringvalidateReferenceName(String referenceName)Validates whether a string is a valid reference-name.static StringvalidateReferenceNameOrHash(String ref)Validates whether a string is a valid reference name or hash.static StringvalidateRepo(String repo)Validates whether a string is a valid repository ID.
-
-
-
Field Detail
-
OWNER_REGEX
public static final String OWNER_REGEX
- See Also:
- Constant Field Values
-
REPO_REGEX
public static final String REPO_REGEX
- See Also:
- Constant Field Values
-
HASH_REGEX
public static final String HASH_REGEX
- See Also:
- Constant Field Values
-
REF_NAME_REGEX
public static final String REF_NAME_REGEX
- See Also:
- Constant Field Values
-
REF_NAME_OR_HASH_REGEX
public static final String REF_NAME_OR_HASH_REGEX
- See Also:
- Constant Field Values
-
REPO_PATTERN
public static final Pattern REPO_PATTERN
-
OWNER_PATTERN
public static final Pattern OWNER_PATTERN
-
HASH_PATTERN
public static final Pattern HASH_PATTERN
-
REF_NAME_PATTERN
public static final Pattern REF_NAME_PATTERN
-
REF_NAME_OR_HASH_PATTERN
public static final Pattern REF_NAME_OR_HASH_PATTERN
-
INVALID_REPO_IDS
public static final Collection<String> INVALID_REPO_IDS
Invalid owner/repo names that represent current and reserved URI path elements.
-
REPO_MESSAGE
public static final String REPO_MESSAGE
- See Also:
- Constant Field Values
-
OWNER_MESSAGE
public static final String OWNER_MESSAGE
- See Also:
- Constant Field Values
-
HASH_MESSAGE
public static final String HASH_MESSAGE
- See Also:
- Constant Field Values
-
REF_NAME_MESSAGE
public static final String REF_NAME_MESSAGE
- See Also:
- Constant Field Values
-
REF_NAME_OR_HASH_MESSAGE
public static final String REF_NAME_OR_HASH_MESSAGE
- See Also:
- Constant Field Values
-
-
Method Detail
-
isValidOwner
public static boolean isValidOwner(String repoOwner)
Just checks whether a string is a valid repository owner, but doesn't throw an exception.- See Also:
validateOwner(String)
-
validateOwner
public static String validateOwner(String owner)
Validates whether a string is a valid repository ID.The rules are: "start with a letter, followed by letters, digits, ._- characters and not be equal to \'config\', \'contents\', \'trees\'"
- Parameters:
owner- the repository ID string to test.
-
isValidRepo
public static boolean isValidRepo(String repo)
Just checks whether a string is a valid repository ID, but doesn't throw an exception.- See Also:
validateRepo(String)
-
validateRepo
public static String validateRepo(String repo)
Validates whether a string is a valid repository ID.The rules are: "start with a letter, followed by letters, digits, ._- characters and not be equal to \'config\', \'contents\', \'trees\'"
- Parameters:
repo- the repository ID string to test.
-
isValidReferenceName
public static boolean isValidReferenceName(String referenceName)
Just checks whether a string is a valid reference-name, but doesn't throw an exception.- See Also:
validateReferenceName(String)
-
isValidHash
public static boolean isValidHash(String hash)
Just checks whether a string is a valid hash, but doesn't throw an exception.- See Also:
validateHash(String)
-
isValidReferenceNameOrHash
public static boolean isValidReferenceNameOrHash(String ref)
Just checks whether a string is a valid reference-name (as perisValidReferenceName(String)) or a valid hash (as perisValidHash(String)).
-
validateReferenceName
public static String validateReferenceName(String referenceName)
Validates whether a string is a valid reference-name.The rules are: "start with a letter, followed by letters, digits, a ./_- character, not end with a slash, not contain .."
- Parameters:
referenceName- the reference name string to test.
-
validateHash
public static String validateHash(String referenceName)
Validates whether a string is a valid hash.The rules are: "consist of the hex representation of 8-32 bytes"
- Parameters:
referenceName- the reference name string to test.
-
validateReferenceNameOrHash
public static String validateReferenceNameOrHash(String ref)
Validates whether a string is a valid reference name or hash.See
validateReferenceName(String)andvalidateHash(String)for the rules.- Parameters:
ref- the reference name string to test.
-
-