Validation is being bypassed by custom UI

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 (${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).

Thanks for the detailed question. What happens is that the generator which generates your default GUI (in${MY_USERNAME}/client/) copies the validation setting from the application model (application.alan) to the gui model (model.alan). Because you are writing a custom gui it is necessary to set the validation there as well, like so:

'Topic name': text validate: "[a-z]+"

notice the lack of the @ here.

1 Like

@Elgar_de_Groot can you also use the expression from the application.alan file, instead of writing it again in your model.alan file? That would ensure that the two are always in sync.

@gjkunst At this point that is not supported