mirror of
https://github.com/ha7ilm/openwebrx.git
synced 2026-04-21 06:13:45 +00:00
add regex validator
This commit is contained in:
parent
49577953c6
commit
a880b1f6f9
2 changed files with 22 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from abc import ABC, abstractmethod
|
||||
from functools import reduce
|
||||
from operator import or_
|
||||
import re
|
||||
|
||||
|
||||
class ValidatorException(Exception):
|
||||
|
|
@ -78,6 +79,14 @@ class NumberValidator(OrValidator):
|
|||
super().__init__(IntegerValidator(), FloatValidator())
|
||||
|
||||
|
||||
class RegexValidator(Validator):
|
||||
def __init__(self, regex: re.Pattern):
|
||||
self.regex = regex
|
||||
|
||||
def isValid(self, value):
|
||||
return self.regex.match(value) is not None
|
||||
|
||||
|
||||
validator_types = {
|
||||
"string": StringValidator,
|
||||
"str": StringValidator,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue