yuktiyuktaṃ vaco grāhyaṃ bālād api śukād api
yukti hīnam, vacas tyājyaṃ vṛddhād api śukād api
Whatever is based on sound reasoning ought to be accepted, even if it proceeds from a boy or parrot. Whatever is not so based ought to be rejected, even if it is uttered by an old man or the sage Śuka himself.
We can find a similar verse from Yoga Vasistha. i.e
युक्तियुक्तमुपादेयं वचनं बालकादपि ।
अन्यत्तृणमिव त्याज्यमप्युक्तं पद्मजन्मना ॥ ३ ॥
yuktiyuktamupādeyaṃ vacanaṃ bālakādapi |
anyattṛṇamiva tyājyamapyuktaṃ padmajanmanā || 3 ||
Words conformable with reason are to be received even if spoken by boys; otherwise, they are to be rejected as straws though pronounced by the lotus-born.
Source - Yoga Vasitha [2.18.3]