Skip to content

Conversation

@doc-han
Copy link
Contributor

@doc-han doc-han commented Nov 18, 2025

Description

This PR add validation for edge expressions when you switch the condition to it. makes sure to show an error when its blank.

Closes #3704

Validation steps

  1. Pick an edge
  2. switch to "Match a Javascript Expression"
  3. If it's empty, then expect an error form validation to be shown below the input in red.
  4. If it's not empty, try emptying it and expect the same outcome.

Additional notes for the reviewer

  1. (Is there anything else the reviewer should know or look out for?)

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

Pre-submission checklist

  • I have performed a self-review of my code.
  • I have implemented and tested all related authorization policies. (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

@doc-han doc-han linked an issue Nov 18, 2025 that may be closed by this pull request
@github-project-automation github-project-automation bot moved this to New Issues in v2 Nov 18, 2025
@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.80%. Comparing base (0d86986) to head (c6c681c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4009      +/-   ##
==========================================
+ Coverage   88.76%   88.80%   +0.04%     
==========================================
  Files         422      422              
  Lines       19106    19106              
==========================================
+ Hits        16959    16968       +9     
+ Misses       2147     2138       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@doc-han
Copy link
Contributor Author

doc-han commented Nov 19, 2025

While working on this. spotted some wrong behaviours in the coloring of edges red based on the errors they were facing.
something not clear in the below code.

Object.keys(formState.values).forEach(fieldName => {
const fieldMeta = form.getFieldMeta(fieldName);
// Only include fields that have been touched/interacted with
// This preserves server errors for untouched fields
if (fieldMeta?.isTouched || fieldMeta?.isDirty) {
// Get client validation errors (exclude collaborative errors from errorMap)
const meta = fieldMeta as unknown as Record<string, unknown>;
const errorMap = (meta?.errorMap as Record<string, unknown>) || {};
// Filter out collaborative errors - only send client validation errors
const clientValidationErrors = (fieldMeta?.errors || []).filter(
(error: unknown) => {
// If this error matches the collaborative error, exclude it
const collaborativeError = errorMap.collaborative;
return error !== collaborativeError;
}
);
if (clientValidationErrors.length > 0) {
// Field has client validation errors
clientErrors[fieldName] = clientValidationErrors.map(
(e: unknown) => (typeof e === 'string' ? e : String(e))
);
} else {
// Field is valid or only has collaborative errors - send empty array to clear
clientErrors[fieldName] = [];
}
}
});

@doc-han doc-han force-pushed the 3704-add-validation-for-edge-js-expressions branch from 55de1d2 to c6c681c Compare November 19, 2025 02:58
Copy link
Contributor

@elias-ba elias-ba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @doc-han I see 3 things that look like problems we need to address. Now I am not super sure whether this is related to this issue / pr.

  1. When I type in the edge label I don't see it appear in the edge
  2. When I type a valid JS Expression I don't see the error disappear; it stays
  3. When I hit the save button, I see that Edges: [object Oject] in the error message.
Image

@github-project-automation github-project-automation bot moved this from New Issues to In review in v2 Nov 19, 2025
@doc-han
Copy link
Contributor Author

doc-han commented Nov 19, 2025

Nice catch @elias-ba
going over it once again.

@doc-han
Copy link
Contributor Author

doc-han commented Nov 19, 2025

Several things out of scope of this PR in relation to what you raised @elias-ba.
Will spend the rest of the day on this actually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

Add validation for edge JS expressions

3 participants