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 StringREF_NAME_MESSAGEstatic StringREF_NAME_OR_HASH_MESSAGEstatic PatternREF_NAME_OR_HASH_PATTERNstatic StringREF_NAME_OR_HASH_REGEXstatic PatternREF_NAME_PATTERNstatic StringREF_NAME_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 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 StringvalidateHash(String referenceName)Validates whether a string is a valid hash.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.
-
-
-
Field Detail
-
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
-
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
-
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
-
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.
-
-