parent
2fb40ff443
commit
c97fd60c25
|
|
@ -109,19 +109,27 @@ func TypeSafetyCheck(name string, value string, argumentType string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func typeSafetyCheckRegex(name string, value string, argumentType string) error {
|
func typeSafetyCheckRegex(name string, value string, argumentType string) error {
|
||||||
pattern, found := typecheckRegex[argumentType]
|
pattern := ""
|
||||||
|
|
||||||
if !found {
|
if strings.HasPrefix(argumentType, "regex:") {
|
||||||
return errors.New("argument type not implemented " + argumentType)
|
pattern = strings.Replace(argumentType, "regex:", "", 1)
|
||||||
|
} else {
|
||||||
|
found := false
|
||||||
|
pattern, found = typecheckRegex[argumentType]
|
||||||
|
|
||||||
|
if !found {
|
||||||
|
return errors.New("argument type not implemented " + argumentType)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
matches, _ := regexp.MatchString(pattern, value)
|
matches, _ := regexp.MatchString(pattern, value)
|
||||||
|
|
||||||
if !matches {
|
if !matches {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"name": name,
|
"name": name,
|
||||||
"value": value,
|
"value": value,
|
||||||
"type": argumentType,
|
"type": argumentType,
|
||||||
|
"pattern": pattern,
|
||||||
}).Warn("Arg type check safety failure")
|
}).Warn("Arg type check safety failure")
|
||||||
|
|
||||||
return errors.New("invalid argument, doesn't match " + argumentType)
|
return errors.New("invalid argument, doesn't match " + argumentType)
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,11 @@ class ArgumentForm extends window.HTMLElement {
|
||||||
domEl.setAttribute('step', '1')
|
domEl.setAttribute('step', '1')
|
||||||
} else {
|
} else {
|
||||||
domEl = document.createElement('input')
|
domEl = document.createElement('input')
|
||||||
|
|
||||||
|
if (arg.type.startsWith(':regex')) {
|
||||||
|
domEl.setAttribute('pattern', arg.type.replace('regex:', ''))
|
||||||
|
}
|
||||||
|
|
||||||
domEl.onchange = () => {
|
domEl.onchange = () => {
|
||||||
const validateArgumentTypeArgs = {
|
const validateArgumentTypeArgs = {
|
||||||
value: domEl.value,
|
value: domEl.value,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue