You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.4 KiB
59 lines
1.4 KiB
@startuml
|
|
|
|
abstract class Validator {
|
|
+ validate(name: string, val: mixed): array
|
|
+ then(other: Validator): Validator
|
|
}
|
|
|
|
class ComposedValidator extends Validator {
|
|
- first: Validator
|
|
- then: Validator
|
|
|
|
+ __construct(first: Validator, then: Validator)
|
|
validate(name: string, val: mixed): array
|
|
}
|
|
|
|
class SimpleFunctionValidator extends Validator {
|
|
- predicate: callable
|
|
- error_factory: callable
|
|
|
|
+ __construct(predicate: callable, errorsFactory: callable)
|
|
+ validate(name: string, val: mixed): array
|
|
}
|
|
|
|
class ValidationFail implements JsonSerialize {
|
|
- kind: string
|
|
- message: string
|
|
|
|
+ __construct(kind: string, message: string)
|
|
+ getMessage(): string
|
|
+ getKind(): string
|
|
+ jsonSerialize()
|
|
|
|
+ <u>notFound(message: string): ValidationFail
|
|
}
|
|
|
|
class FieldValidationFail extends ValidationFail {
|
|
- fieldName: string
|
|
+ __construct(fieldName: string, message: string)
|
|
+ getFieldName(): string
|
|
+ jsonSerialize()
|
|
|
|
+ <u>invalidChars(fieldName: string): FieldValidationFail
|
|
+ <u>empty(fieldName: string): FieldValidationFail
|
|
+ <u>missing(fieldName: string): FieldValidationFail
|
|
}
|
|
|
|
|
|
class Validation {
|
|
<u> + validate(val: mixed, valName: string, failures: &array, validators: Validator...): bool
|
|
}
|
|
|
|
class Validators {
|
|
+ <u>nonEmpty(): Validator
|
|
+ <u>shorterThan(limit: int): Validator
|
|
+ <u>userString(maxLen: int): Validator
|
|
}
|
|
|
|
|
|
@enduml |