A command which has validation is being bypassed by custom widget which executes that command. This is the command:
'Submit topic': command {
'Topic name': text @validate: "[a-z]+"
} => update .'Topics' = create (
'Topic name' = @ .'Topic name'
)
and this is the Topics collection:
'Topics': collection ['Topic name']
can-create: user
can-delete: user .'Type'?'Admin'
{
can-update: user .'Type'?'Admin'
'Topic name': text @validate: "[a-z]+"
}
In both of them I have put @validate: "[a-z]+"
for the Topic name
field. In the default client (https://app.alan-platform.com/${MY_USERNAME}/client/) when I try to create a topic with a name of “123”, or “” (empty) it gives an popup error There are invalid fields remaining. Check all fields and try again.
which prevents me from creating a topic with such a name.
But in my custom client I can have a widget which executes this command and creates Topics with invalid fields.
This is the part of the widget that executes the command:
command popup.alan
binding 'node' {
'title widget': widget
'command': binding 'operation' {
'widget' on 'parameters': widget
}
'command name': text
'show popup': stategroup default: 'no' (
'yes' { }
'no' { }
)
}
// ....... a button control
'enabled' = switch root ::'command'.'executable' (
|'yes' as $ => 'yes' {
'onclick' = [
$ >>'execute',
root set state 'show popup': 'no' ( )
]
}
|'no' => 'no' { }
and the widget which I’ve used to bind the command’s Topic name
property:
text input.alan
binding 'node' {
'text': binding 'text' {
}
}
control 'text input' {
'text' = switch ::'text'.'is set' (
|'yes' as $ => $ .'text'
|'no' => ""
)
'on change' = root ::'text'>>'update text' ( text argument )
'enabled' = 'yes' { }
'clear button' = 'no' { }
'warn about invisibles' = 'no' { }
'options' = 'no' { }
}
PS. For the last widget I’ve asked a question on the forum to get the two-way binding (Text input 'two-way binding' for a command - #3 by peter_c7).