-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add Default Value Option #216
base: master
Are you sure you want to change the base?
Conversation
You can add a default value by using 'default:' with single value. For example: `default:ITEM_ID`
Kudos, SonarCloud Quality Gate passed! |
Hi @mhkhoraidah sorry for the delayed response but this PR does not pass the tests so we could not merge it. I really like the change but we cannot merge it 😅 |
const addEnumValues = require('../utils/enumValues'); | ||
const { refSchema, formatRefSchema } = require('../utils/refSchema'); | ||
|
||
const getSchema = (entity, message) => (type, enumValues = [], jsonOptions = {}) => { | ||
const getSchema = (entity, message) => (type, defaultValue = '', enumValues = [], jsonOptions = {}) => { |
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.
I don't think we should add a default value for this property: it should be optional and, therefore, remain as undefined
if not specified.
Also, depending on the type, an empty string wouldn't always make sense. On a numeric field, for example, we may want need to use a zero or something else, as an empty string could be considered a NaN
value. For boolean fields, a default of true
or false
would make more sense. These are just examples, but this is to illustrate that we should not use an empty string as a default for every field.
transforms/utils/defaultValue.js
Outdated
@@ -0,0 +1,5 @@ | |||
const addDefaultValue = (value = '') => { |
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.
Kudos, SonarCloud Quality Gate passed! |
You can add a default value by using 'default:' with single value.
For example:
default:ITEM_ID
What kind of change does this PR introduce? (check at least one)
Description: default value example
\examples\parameters\default.js
and add run command 'npm run parameters:default'