com.netflix.gradle.plugins.rpm.validation.RpmPackageNameAttributeValidator.groovy Maven / Gradle / Ivy
package com.netflix.gradle.plugins.rpm.validation
import com.netflix.gradle.plugins.packaging.validation.SystemPackagingAttributeValidator
class RpmPackageNameAttributeValidator implements SystemPackagingAttributeValidator {
/**
* Per RPM manpage a valid
* package name has to follow these conventions:
*
* abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._+
*
* @param packageName Package name
* @return Result
*/
@Override
boolean validate(String packageName) {
matchesExpectedCharacters(packageName)
}
private boolean matchesExpectedCharacters(String packageName) {
packageName ==~ /[a-zA-Z0-9-._+]+/
}
@Override
String getErrorMessage(String attribute) {
"Invalid package name '$attribute' - a valid package name must only contain [a-zA-Z0-9-._+]"
}
}