Renamed the AgentNameValidationRule type in the library target as CamelCaseValidationRule.
This commit is contained in:
+10
-8
@@ -12,7 +12,8 @@
|
||||
//
|
||||
// ===----------------------------------------------------------------------===
|
||||
|
||||
struct AgentNameValidationRule: InputValidationRule {
|
||||
/// A validation rule type that checks whether an input is camel-case or not.
|
||||
struct CamelCaseValidationRule: InputValidationRule {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
@@ -30,18 +31,18 @@ struct AgentNameValidationRule: InputValidationRule {
|
||||
|
||||
// MARK: - Definitions
|
||||
|
||||
extension InputValidationRule where Self == AgentNameValidationRule {
|
||||
extension InputValidationRule where Self == CamelCaseValidationRule {
|
||||
|
||||
// MARK: Constants
|
||||
|
||||
/// A validation rule that checks whether an input is camel-cased or not.
|
||||
static var agentName: Self { .init() }
|
||||
static var camelCase: Self { .init() }
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
private extension AgentNameValidationRule {
|
||||
private extension CamelCaseValidationRule {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
@@ -58,9 +59,9 @@ private extension AgentNameValidationRule {
|
||||
}
|
||||
|
||||
guard input.fullyMatch(
|
||||
pattern: .init(format: .Pattern.agentName)
|
||||
pattern: .init(format: .Pattern.camelCase)
|
||||
) else {
|
||||
throw InputValidationError.inputNotAgentName
|
||||
throw InputValidationError.inputNotCamelCase
|
||||
}
|
||||
|
||||
return true
|
||||
@@ -71,6 +72,7 @@ private extension AgentNameValidationRule {
|
||||
// MARK: - Constants
|
||||
|
||||
private extension String.Pattern {
|
||||
/// A regular expression pattern to match the user agent name input against.
|
||||
static let agentName = "^([A-Z]([a-z]|[0-9])+)+$"
|
||||
/// A regular expression pattern that represents camel-cased inputs.
|
||||
static let camelCase = "([A-Z]([a-z]|[0-9])+)+"
|
||||
|
||||
}
|
||||
@@ -107,6 +107,6 @@ private extension SecureValidationRule {
|
||||
// MARK: - Constants
|
||||
|
||||
private extension String.Pattern {
|
||||
/// A regular expression pattern to match the security inputs against.
|
||||
/// A regular expression pattern that represents security inputs.
|
||||
static let securityInput = "^([a-z]|[A-Z]){%d}$"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user