Skip to content

Commit d8e2740

Browse files
authored
Merge pull request #2187 from CodeNow/add-env-validation
add env validation
2 parents 2343db4 + 6be8240 commit d8e2740

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

client/directives/environment/modals/forms/formEnvironmentVariables/environmentVariablesTableView.jade

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,37 @@ ul.tbody(
33
ng-init = "vars = [\
44
{key: 'hello', value: '●●●', duplicate: true},\
55
{key: 'hi', value: '●●●●●●', duplicate: false},\
6-
{key: 'sup', value: '●●●●●●●●●', duplicate: false},\
6+
{key: 'sup', value: '●●●●●●●●●', duplicate: false},\
77
{key: 'hey', value: '●●●', duplicate: false},\
88
{key: 'hello', value: '●●●●●●', duplicate: true}\
99
]"
1010
)
1111
li.tr
1212
label.grid-block.align-center.cell
13+
//- this pattern should also (but does not currently) validate that the first character is not a number
1314
//- [disable] when loading
14-
input.input.monospace(
15+
input.input.input-validate.monospace(
16+
name = "key"
17+
ng-model = "key"
18+
ng-required = "true"
19+
ng-pattern = "/^([A-Za-z]|[0-9]|_)+$/"
1520
placeholder = "Key"
21+
spellcheck = "false"
1622
)
1723
label.grid-block.align-center.cell
1824
//- [disable] when loading
19-
input.input.monospace(
25+
input.input.input-validate.monospace(
26+
name = "value"
27+
ng-model = "value"
28+
ng-required = "true"
29+
ng-pattern = "/^([A-Za-z]|[0-9]|_)+$/"
2030
placeholder = "Value"
31+
spellcheck = "false"
2132
)
2233
.grid-block.align-center.justify-right.cell.cell-action
2334
//- [disable] when loading
2435
button.grid-block.align-center.justify-center.btn.btn-xs.white(
36+
ng-disabled = "envVarForm.$invalid"
2537
ng-init = "saving = null"
2638
)
2739
//- show when loading

client/directives/environment/modals/forms/formEnvironmentVariables/viewFormEnvironmentVariables.jade

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
ng-if = "!$root.featureFlags.connections"
55
)
66
.label-col Environment Variables
7-
.small.text-gray Use environment variables for sensitive information you need to build or run your code.
7+
.small.text-gray Use environment variables for sensitive information you need to build or run your code. 
8+
span(
9+
ng-class = "{'text-red': envVarForm.$error.pattern}"
10+
) Keys and values may be alphanumeric characters or underscores, but may not start with a number.
811
//- |  
912
//- a.link(
1013
//- href = "//runnable.com/docs"

client/directives/environment/modals/serverModalView.jade

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ section.modal-body(
183183
ports-form
184184
)
185185
.modal-form(
186+
ng-form = "envVarForm"
186187
ng-include = "'viewFormEnvironmentVariables'"
187188
ng-if = "SMC.selectedTab === 'env'"
188189
)

0 commit comments

Comments
 (0)