-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: The user input parameter was set to non mandatory, but after re entering the canvas editing, it became a mandatory parameter #4521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ "type": "error", "message": "The line `item.required = item.required == undefined ? item.is_required : item.required;` can be simplified to use JavaScript's nullish coalescing operator (`??`) and logical OR operator (||) for better readability.", "solutions": [ "Replace the line with:\n```javascript\nitem.required ||= item.is_required;\n```\nor if you prefer a more explicit version based on truthy values of `null`, `undefined`, or empty strings:\n```javascript\n// Option 1: Only consider non-empty strings or falsy but not true for required field.\ncurrentRequired = !!(item.required || '');\nif (!currentRequired && !!item.is_required) {\n currentRequired = item.is_required;\n}\notherwise...\n// Option 2: Use ternary operator directly.\nitem.required = item.required ?? item.is_required;\nmaybeOption3..\n```\nor simply,\nnormalized option without using conditionals for clarity:\n```javascript\nitem.normalizedRequiredValue = normalizeBoolean(item?.required ?? ''); function normalizeBoolean(rawValue) { // Helper function could also apply custom parsing logic here if needed.\n return rawValue !== false && rawValue !== '';\n} ```\n**Important Note:** Ensure consistency within your application regarding how boolean flags are handled before applying these solutions." ] } # Updated TypeScript Function Definition: --- Now, please ensure that all files referenced in the above changes have their respective imports included: - Import lodash for array cloning functionality. - Import Vue components necessary for dynamic rendering within Vue templates. Here is how it would look in one comprehensive solution format: ```typescript import { ref, onMounted } from 'vue'; import { set, cloneDeep} from 'lodash'; import Sortable from 'sortablejs'; onMounted(async () => { const inputFieldList = ref<Array<{ label?: string, field?: string, type: string, value?: any, input_type?: string, options?: object, required?: boolean | null }>>([ ... ]); } /* Define a utility/helper function called normalizeBoolean here */ export async function validateInput(value): Promise<boolean> { /* Check against some specific criteria to determine validity. For example, valid inputs might include true/false, strings like 'enabled', 'yes', numbers 1/0, etc. */ try { if (/^true|false$/i.test(String(value))) {// Assuming 'value' is either a string or number return String(value).toLowerCase() === 'true'; // Convert the given string into lower case for comparison ('true' & 'False' both will be considered as True) } throw new Error("Invalid boolean value!"); } catch(err){ console.error('An error occurred while validating:', err); } }; // And then call this helper whenever you need to validate any Boolean values.