|
|
@@ -46,6 +46,25 @@ func (this *MaxLenghtValidator) Validate(value any) bool {
|
|
|
return len(v) <= this.length
|
|
|
}
|
|
|
|
|
|
+type ExactLenghtValidator struct {
|
|
|
+ length int
|
|
|
+}
|
|
|
+
|
|
|
+func NewExactLenghtValidator(length int) *ExactLenghtValidator {
|
|
|
+ return &ExactLenghtValidator{
|
|
|
+ length: length,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (this *ExactLenghtValidator) Validate(value any) bool {
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ return len(v) == this.length
|
|
|
+}
|
|
|
+
|
|
|
type RegexValidator struct {
|
|
|
expression *regexp.Regexp
|
|
|
}
|