express.js route not recognizing null value for conditional response
I am trying to render an alternative response to my express.js route when a date value in the parameter ends up being invalid. When I see an invalid date the value ends up being null so in my if statement in the middleware I test for a truthy value and if it is not truthy i serve up an alternative response.
What I get is the true value even though the value of the date is null. Here is an example:
api/timestamp/hello is my route.
A valid date should look like this: {"unix":1546214400000,"utc":"Mon, 31 Dec 2018 00:00:00 GMT"}
An invalid date like 'hello' should look like this {'error': 'Invalid Date'}
The code returns the correct value if the date is valid, but if the date is invalid I get {"unix":null,"utc":"Invalid Date"}
instead of {'error': 'Invalid Date'}
Below is the code.
app.get('/api/timestamp/:date', (req,res) => {
let date = new Date(req.params.date);
if (date === null) {
res.send({'error': 'Invalid Date'});
} else {
let unix = date.getTime();
let utc = date.toUTCString();
res.send({unix, utc});
}
});
I'm relatively new to express and Node.js for that matter. Any thoughts on why the null value is not being recognized?
node.js express ecmascript-6
add a comment |
I am trying to render an alternative response to my express.js route when a date value in the parameter ends up being invalid. When I see an invalid date the value ends up being null so in my if statement in the middleware I test for a truthy value and if it is not truthy i serve up an alternative response.
What I get is the true value even though the value of the date is null. Here is an example:
api/timestamp/hello is my route.
A valid date should look like this: {"unix":1546214400000,"utc":"Mon, 31 Dec 2018 00:00:00 GMT"}
An invalid date like 'hello' should look like this {'error': 'Invalid Date'}
The code returns the correct value if the date is valid, but if the date is invalid I get {"unix":null,"utc":"Invalid Date"}
instead of {'error': 'Invalid Date'}
Below is the code.
app.get('/api/timestamp/:date', (req,res) => {
let date = new Date(req.params.date);
if (date === null) {
res.send({'error': 'Invalid Date'});
} else {
let unix = date.getTime();
let utc = date.toUTCString();
res.send({unix, utc});
}
});
I'm relatively new to express and Node.js for that matter. Any thoughts on why the null value is not being recognized?
node.js express ecmascript-6
add a comment |
I am trying to render an alternative response to my express.js route when a date value in the parameter ends up being invalid. When I see an invalid date the value ends up being null so in my if statement in the middleware I test for a truthy value and if it is not truthy i serve up an alternative response.
What I get is the true value even though the value of the date is null. Here is an example:
api/timestamp/hello is my route.
A valid date should look like this: {"unix":1546214400000,"utc":"Mon, 31 Dec 2018 00:00:00 GMT"}
An invalid date like 'hello' should look like this {'error': 'Invalid Date'}
The code returns the correct value if the date is valid, but if the date is invalid I get {"unix":null,"utc":"Invalid Date"}
instead of {'error': 'Invalid Date'}
Below is the code.
app.get('/api/timestamp/:date', (req,res) => {
let date = new Date(req.params.date);
if (date === null) {
res.send({'error': 'Invalid Date'});
} else {
let unix = date.getTime();
let utc = date.toUTCString();
res.send({unix, utc});
}
});
I'm relatively new to express and Node.js for that matter. Any thoughts on why the null value is not being recognized?
node.js express ecmascript-6
I am trying to render an alternative response to my express.js route when a date value in the parameter ends up being invalid. When I see an invalid date the value ends up being null so in my if statement in the middleware I test for a truthy value and if it is not truthy i serve up an alternative response.
What I get is the true value even though the value of the date is null. Here is an example:
api/timestamp/hello is my route.
A valid date should look like this: {"unix":1546214400000,"utc":"Mon, 31 Dec 2018 00:00:00 GMT"}
An invalid date like 'hello' should look like this {'error': 'Invalid Date'}
The code returns the correct value if the date is valid, but if the date is invalid I get {"unix":null,"utc":"Invalid Date"}
instead of {'error': 'Invalid Date'}
Below is the code.
app.get('/api/timestamp/:date', (req,res) => {
let date = new Date(req.params.date);
if (date === null) {
res.send({'error': 'Invalid Date'});
} else {
let unix = date.getTime();
let utc = date.toUTCString();
res.send({unix, utc});
}
});
I'm relatively new to express and Node.js for that matter. Any thoughts on why the null value is not being recognized?
node.js express ecmascript-6
node.js express ecmascript-6
edited Jan 1 at 19:19
Joe LoPresti
asked Jan 1 at 18:18
Joe LoPrestiJoe LoPresti
62
62
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Q: Wouldn't it make sense to check for a valid date BEFORE you try converting it to Unix and UTC?
app.get('/api/timestamp/:date', (req,res) => {
let date = new Date(req.params.date);
if (req.params.date && date instanceOf Date) {
let unix = date.getTime();
let utc = date.toUTCString();
res.send({unix, utc});
} else {
res.send({'error': 'Invalid Date'});
}
}
Sure that does make sense to me. I went ahead and did that. I do need to declare the date variable outside the if statement because req.params.date would still return a true value, but if I pass it through the Date method that's when I see the null value. I'm still getting the same response even though I convert the date to unix & utc.
– Joe LoPresti
Jan 1 at 18:29
OK - you can check for both "date != null" and "date is valid". I've updated the example.
– paulsm4
Jan 1 at 21:32
add a comment |
The way you are building your response, node thinks it's a destructuring assignment, therefore you get the strange response.
To get what you want you can make something like this:
app.get('/api/timestamp/:date?', (req,res) => {
if(req.params.date){
let date = new Date(req.params.date);
let unix = date.getTime();
let utc = date.toUTCString();
if(unix) return res.send({unix,utc})
res.send({'error': 'Invalid Date'});
} else
res.send({'error': 'Invalid Date'});
})
I didn't even think about it being read as a destructuring assignment. That would make a lot of sense. I should clarify more on this problem. If req.params.date is null then I want to use the current timestamp, if it is invalid, then I want to serve the error JSON response, if it is valid I want to serve that current timestamp.
– Joe LoPresti
Jan 1 at 18:49
hi, so if it's a valid date, you want to return something like {date:1546368889275}? i'll edit my answer accordingly
– Sombriks
Jan 1 at 18:55
Thank you. So if it's a valid date I want it to return {"unix":1451001600000,"utc":"Fri, 25 Dec 2015 00:00:00 GMT"}. If it's an invalid date, I want it to return {'error': 'Invalid Date'}. If there is no date in the param, I'd like it to return the current timestamp, which I can currently do by just declaring a route for /api/timestamp/.
– Joe LoPresti
Jan 1 at 19:00
1
hi, fixed the answer again. in resume you check if uni is NaN, if not you can use the res.send({unix,utc}) idiom with no concerns.
– Sombriks
Jan 1 at 19:32
Thanks this definitely worked! Now I need to figure out how to get it to recognize unix dates :).
– Joe LoPresti
Jan 2 at 0:54
add a comment |
Date constructor returns date to 1 January 1970 if the parameter is null and I can't think of any case it would return null
.
Which means that your first check will always be false since your are using strict equality.
Probably you better be checking if req.params.date is truthy
and unix
is a valid timestamp
Hope this helps
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53997825%2fexpress-js-route-not-recognizing-null-value-for-conditional-response%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Q: Wouldn't it make sense to check for a valid date BEFORE you try converting it to Unix and UTC?
app.get('/api/timestamp/:date', (req,res) => {
let date = new Date(req.params.date);
if (req.params.date && date instanceOf Date) {
let unix = date.getTime();
let utc = date.toUTCString();
res.send({unix, utc});
} else {
res.send({'error': 'Invalid Date'});
}
}
Sure that does make sense to me. I went ahead and did that. I do need to declare the date variable outside the if statement because req.params.date would still return a true value, but if I pass it through the Date method that's when I see the null value. I'm still getting the same response even though I convert the date to unix & utc.
– Joe LoPresti
Jan 1 at 18:29
OK - you can check for both "date != null" and "date is valid". I've updated the example.
– paulsm4
Jan 1 at 21:32
add a comment |
Q: Wouldn't it make sense to check for a valid date BEFORE you try converting it to Unix and UTC?
app.get('/api/timestamp/:date', (req,res) => {
let date = new Date(req.params.date);
if (req.params.date && date instanceOf Date) {
let unix = date.getTime();
let utc = date.toUTCString();
res.send({unix, utc});
} else {
res.send({'error': 'Invalid Date'});
}
}
Sure that does make sense to me. I went ahead and did that. I do need to declare the date variable outside the if statement because req.params.date would still return a true value, but if I pass it through the Date method that's when I see the null value. I'm still getting the same response even though I convert the date to unix & utc.
– Joe LoPresti
Jan 1 at 18:29
OK - you can check for both "date != null" and "date is valid". I've updated the example.
– paulsm4
Jan 1 at 21:32
add a comment |
Q: Wouldn't it make sense to check for a valid date BEFORE you try converting it to Unix and UTC?
app.get('/api/timestamp/:date', (req,res) => {
let date = new Date(req.params.date);
if (req.params.date && date instanceOf Date) {
let unix = date.getTime();
let utc = date.toUTCString();
res.send({unix, utc});
} else {
res.send({'error': 'Invalid Date'});
}
}
Q: Wouldn't it make sense to check for a valid date BEFORE you try converting it to Unix and UTC?
app.get('/api/timestamp/:date', (req,res) => {
let date = new Date(req.params.date);
if (req.params.date && date instanceOf Date) {
let unix = date.getTime();
let utc = date.toUTCString();
res.send({unix, utc});
} else {
res.send({'error': 'Invalid Date'});
}
}
edited Jan 1 at 21:34
answered Jan 1 at 18:23
paulsm4paulsm4
79.8k9101128
79.8k9101128
Sure that does make sense to me. I went ahead and did that. I do need to declare the date variable outside the if statement because req.params.date would still return a true value, but if I pass it through the Date method that's when I see the null value. I'm still getting the same response even though I convert the date to unix & utc.
– Joe LoPresti
Jan 1 at 18:29
OK - you can check for both "date != null" and "date is valid". I've updated the example.
– paulsm4
Jan 1 at 21:32
add a comment |
Sure that does make sense to me. I went ahead and did that. I do need to declare the date variable outside the if statement because req.params.date would still return a true value, but if I pass it through the Date method that's when I see the null value. I'm still getting the same response even though I convert the date to unix & utc.
– Joe LoPresti
Jan 1 at 18:29
OK - you can check for both "date != null" and "date is valid". I've updated the example.
– paulsm4
Jan 1 at 21:32
Sure that does make sense to me. I went ahead and did that. I do need to declare the date variable outside the if statement because req.params.date would still return a true value, but if I pass it through the Date method that's when I see the null value. I'm still getting the same response even though I convert the date to unix & utc.
– Joe LoPresti
Jan 1 at 18:29
Sure that does make sense to me. I went ahead and did that. I do need to declare the date variable outside the if statement because req.params.date would still return a true value, but if I pass it through the Date method that's when I see the null value. I'm still getting the same response even though I convert the date to unix & utc.
– Joe LoPresti
Jan 1 at 18:29
OK - you can check for both "date != null" and "date is valid". I've updated the example.
– paulsm4
Jan 1 at 21:32
OK - you can check for both "date != null" and "date is valid". I've updated the example.
– paulsm4
Jan 1 at 21:32
add a comment |
The way you are building your response, node thinks it's a destructuring assignment, therefore you get the strange response.
To get what you want you can make something like this:
app.get('/api/timestamp/:date?', (req,res) => {
if(req.params.date){
let date = new Date(req.params.date);
let unix = date.getTime();
let utc = date.toUTCString();
if(unix) return res.send({unix,utc})
res.send({'error': 'Invalid Date'});
} else
res.send({'error': 'Invalid Date'});
})
I didn't even think about it being read as a destructuring assignment. That would make a lot of sense. I should clarify more on this problem. If req.params.date is null then I want to use the current timestamp, if it is invalid, then I want to serve the error JSON response, if it is valid I want to serve that current timestamp.
– Joe LoPresti
Jan 1 at 18:49
hi, so if it's a valid date, you want to return something like {date:1546368889275}? i'll edit my answer accordingly
– Sombriks
Jan 1 at 18:55
Thank you. So if it's a valid date I want it to return {"unix":1451001600000,"utc":"Fri, 25 Dec 2015 00:00:00 GMT"}. If it's an invalid date, I want it to return {'error': 'Invalid Date'}. If there is no date in the param, I'd like it to return the current timestamp, which I can currently do by just declaring a route for /api/timestamp/.
– Joe LoPresti
Jan 1 at 19:00
1
hi, fixed the answer again. in resume you check if uni is NaN, if not you can use the res.send({unix,utc}) idiom with no concerns.
– Sombriks
Jan 1 at 19:32
Thanks this definitely worked! Now I need to figure out how to get it to recognize unix dates :).
– Joe LoPresti
Jan 2 at 0:54
add a comment |
The way you are building your response, node thinks it's a destructuring assignment, therefore you get the strange response.
To get what you want you can make something like this:
app.get('/api/timestamp/:date?', (req,res) => {
if(req.params.date){
let date = new Date(req.params.date);
let unix = date.getTime();
let utc = date.toUTCString();
if(unix) return res.send({unix,utc})
res.send({'error': 'Invalid Date'});
} else
res.send({'error': 'Invalid Date'});
})
I didn't even think about it being read as a destructuring assignment. That would make a lot of sense. I should clarify more on this problem. If req.params.date is null then I want to use the current timestamp, if it is invalid, then I want to serve the error JSON response, if it is valid I want to serve that current timestamp.
– Joe LoPresti
Jan 1 at 18:49
hi, so if it's a valid date, you want to return something like {date:1546368889275}? i'll edit my answer accordingly
– Sombriks
Jan 1 at 18:55
Thank you. So if it's a valid date I want it to return {"unix":1451001600000,"utc":"Fri, 25 Dec 2015 00:00:00 GMT"}. If it's an invalid date, I want it to return {'error': 'Invalid Date'}. If there is no date in the param, I'd like it to return the current timestamp, which I can currently do by just declaring a route for /api/timestamp/.
– Joe LoPresti
Jan 1 at 19:00
1
hi, fixed the answer again. in resume you check if uni is NaN, if not you can use the res.send({unix,utc}) idiom with no concerns.
– Sombriks
Jan 1 at 19:32
Thanks this definitely worked! Now I need to figure out how to get it to recognize unix dates :).
– Joe LoPresti
Jan 2 at 0:54
add a comment |
The way you are building your response, node thinks it's a destructuring assignment, therefore you get the strange response.
To get what you want you can make something like this:
app.get('/api/timestamp/:date?', (req,res) => {
if(req.params.date){
let date = new Date(req.params.date);
let unix = date.getTime();
let utc = date.toUTCString();
if(unix) return res.send({unix,utc})
res.send({'error': 'Invalid Date'});
} else
res.send({'error': 'Invalid Date'});
})
The way you are building your response, node thinks it's a destructuring assignment, therefore you get the strange response.
To get what you want you can make something like this:
app.get('/api/timestamp/:date?', (req,res) => {
if(req.params.date){
let date = new Date(req.params.date);
let unix = date.getTime();
let utc = date.toUTCString();
if(unix) return res.send({unix,utc})
res.send({'error': 'Invalid Date'});
} else
res.send({'error': 'Invalid Date'});
})
edited Jan 1 at 19:29
answered Jan 1 at 18:42
SombriksSombriks
1,46932232
1,46932232
I didn't even think about it being read as a destructuring assignment. That would make a lot of sense. I should clarify more on this problem. If req.params.date is null then I want to use the current timestamp, if it is invalid, then I want to serve the error JSON response, if it is valid I want to serve that current timestamp.
– Joe LoPresti
Jan 1 at 18:49
hi, so if it's a valid date, you want to return something like {date:1546368889275}? i'll edit my answer accordingly
– Sombriks
Jan 1 at 18:55
Thank you. So if it's a valid date I want it to return {"unix":1451001600000,"utc":"Fri, 25 Dec 2015 00:00:00 GMT"}. If it's an invalid date, I want it to return {'error': 'Invalid Date'}. If there is no date in the param, I'd like it to return the current timestamp, which I can currently do by just declaring a route for /api/timestamp/.
– Joe LoPresti
Jan 1 at 19:00
1
hi, fixed the answer again. in resume you check if uni is NaN, if not you can use the res.send({unix,utc}) idiom with no concerns.
– Sombriks
Jan 1 at 19:32
Thanks this definitely worked! Now I need to figure out how to get it to recognize unix dates :).
– Joe LoPresti
Jan 2 at 0:54
add a comment |
I didn't even think about it being read as a destructuring assignment. That would make a lot of sense. I should clarify more on this problem. If req.params.date is null then I want to use the current timestamp, if it is invalid, then I want to serve the error JSON response, if it is valid I want to serve that current timestamp.
– Joe LoPresti
Jan 1 at 18:49
hi, so if it's a valid date, you want to return something like {date:1546368889275}? i'll edit my answer accordingly
– Sombriks
Jan 1 at 18:55
Thank you. So if it's a valid date I want it to return {"unix":1451001600000,"utc":"Fri, 25 Dec 2015 00:00:00 GMT"}. If it's an invalid date, I want it to return {'error': 'Invalid Date'}. If there is no date in the param, I'd like it to return the current timestamp, which I can currently do by just declaring a route for /api/timestamp/.
– Joe LoPresti
Jan 1 at 19:00
1
hi, fixed the answer again. in resume you check if uni is NaN, if not you can use the res.send({unix,utc}) idiom with no concerns.
– Sombriks
Jan 1 at 19:32
Thanks this definitely worked! Now I need to figure out how to get it to recognize unix dates :).
– Joe LoPresti
Jan 2 at 0:54
I didn't even think about it being read as a destructuring assignment. That would make a lot of sense. I should clarify more on this problem. If req.params.date is null then I want to use the current timestamp, if it is invalid, then I want to serve the error JSON response, if it is valid I want to serve that current timestamp.
– Joe LoPresti
Jan 1 at 18:49
I didn't even think about it being read as a destructuring assignment. That would make a lot of sense. I should clarify more on this problem. If req.params.date is null then I want to use the current timestamp, if it is invalid, then I want to serve the error JSON response, if it is valid I want to serve that current timestamp.
– Joe LoPresti
Jan 1 at 18:49
hi, so if it's a valid date, you want to return something like {date:1546368889275}? i'll edit my answer accordingly
– Sombriks
Jan 1 at 18:55
hi, so if it's a valid date, you want to return something like {date:1546368889275}? i'll edit my answer accordingly
– Sombriks
Jan 1 at 18:55
Thank you. So if it's a valid date I want it to return {"unix":1451001600000,"utc":"Fri, 25 Dec 2015 00:00:00 GMT"}. If it's an invalid date, I want it to return {'error': 'Invalid Date'}. If there is no date in the param, I'd like it to return the current timestamp, which I can currently do by just declaring a route for /api/timestamp/.
– Joe LoPresti
Jan 1 at 19:00
Thank you. So if it's a valid date I want it to return {"unix":1451001600000,"utc":"Fri, 25 Dec 2015 00:00:00 GMT"}. If it's an invalid date, I want it to return {'error': 'Invalid Date'}. If there is no date in the param, I'd like it to return the current timestamp, which I can currently do by just declaring a route for /api/timestamp/.
– Joe LoPresti
Jan 1 at 19:00
1
1
hi, fixed the answer again. in resume you check if uni is NaN, if not you can use the res.send({unix,utc}) idiom with no concerns.
– Sombriks
Jan 1 at 19:32
hi, fixed the answer again. in resume you check if uni is NaN, if not you can use the res.send({unix,utc}) idiom with no concerns.
– Sombriks
Jan 1 at 19:32
Thanks this definitely worked! Now I need to figure out how to get it to recognize unix dates :).
– Joe LoPresti
Jan 2 at 0:54
Thanks this definitely worked! Now I need to figure out how to get it to recognize unix dates :).
– Joe LoPresti
Jan 2 at 0:54
add a comment |
Date constructor returns date to 1 January 1970 if the parameter is null and I can't think of any case it would return null
.
Which means that your first check will always be false since your are using strict equality.
Probably you better be checking if req.params.date is truthy
and unix
is a valid timestamp
Hope this helps
add a comment |
Date constructor returns date to 1 January 1970 if the parameter is null and I can't think of any case it would return null
.
Which means that your first check will always be false since your are using strict equality.
Probably you better be checking if req.params.date is truthy
and unix
is a valid timestamp
Hope this helps
add a comment |
Date constructor returns date to 1 January 1970 if the parameter is null and I can't think of any case it would return null
.
Which means that your first check will always be false since your are using strict equality.
Probably you better be checking if req.params.date is truthy
and unix
is a valid timestamp
Hope this helps
Date constructor returns date to 1 January 1970 if the parameter is null and I can't think of any case it would return null
.
Which means that your first check will always be false since your are using strict equality.
Probably you better be checking if req.params.date is truthy
and unix
is a valid timestamp
Hope this helps
answered Jan 1 at 22:53


Kevin CoulibalyKevin Coulibaly
1219
1219
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53997825%2fexpress-js-route-not-recognizing-null-value-for-conditional-response%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown