Ma77Ball commented on code in PR #8644:
URL: https://github.com/apache/texera/pull/8644#discussion_r4110234532
##########
frontend/src/app/common/formly/formly-config.ts:
##########
@@ -94,6 +97,23 @@ export const TEXERA_FORMLY_CONFIG = {
{ name: "ui-udf-parameters", component: UiUdfParametersComponent,
wrappers: ["form-field"] },
{ name: "constrainedvalue", component: ConstrainedValueComponent,
wrappers: ["form-field"] },
{ name: "resourcevalue", component: ResourceValueSelectorComponent },
+ {
+ name: "delimiter",
+ component: DelimiterTypeComponent,
+ wrappers: ["form-field"],
+ defaultOptions: {
+ // Shown without waiting for a touch: a delimiter loaded from a saved
workflow can already be
+ // invalid (an old multi-character one), and nobody touches a field
they do not know is wrong.
+ validation: { show: true },
+ validators: {
+ delimiter: {
+ expression: (control: AbstractControl, field: FormlyFieldConfig) =>
+ delimiterError(control.value, delimiterModeOf(field)) ===
undefined,
+ message: delimiterValidationMessage,
Review Comment:
Nit: the `expression` validator computes `delimiterError(...)` only to
compare it against `undefined` and discard the string, then
`delimiterValidationMessage` (line 166) recomputes the very same
`delimiterError(...)` to render the message.
Why it matters: for a match-everything pattern (`.`, `[\s\S]`),
`delimiterError` runs the full ~65k-character `matchesEveryCharacter` scan, and
in the invalid case that scan now runs twice per validation pass (once here,
once in the message). It is only the error path and only for that pattern
class, so it is minor, not a correctness issue.
No suggestion since Formly's split of validator predicate and message
function makes a clean single-evaluation awkward: if you want to avoid the
double scan, cache the last `{value, mode, error}` in a small module-level memo
that both the expression and `delimiterValidationMessage` read, or accept the
current cost as negligible.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]