Why
Some applications may prefer to delay evaluation of the validation.
Pros
- Stack trace leads to the usage location, not the config file.
Cons
- May hide config problems during development & testing.
Dev notes
Possible implementations:
get getter wrapper object?
- Or ES6 Proxy?
Considerations
- Set via an option?
- Per value?
- Set per config set?
Usage?
Option naming:
deferred: true
delayed: true
validate: 'delayed',
validateOn: 'load' | 'access'
- ?
Some Examples
1/3: Per Config: deferred option
import { autoConfig } from '@elite-libs/auto-config';
const config = autoConfig({
port: {
args: ['--port', 'PORT'],
deferred: true,
required: true,
},
});
2/3: autoConfig Instance Default
import { autoConfig } from '@elite-libs/auto-config';
const config = autoConfig({
port: {
args: ['--port', 'PORT'],
required: true,
},
}, {
deferred: true
});
3/3: Global Override
import { autoConfig } from '@elite-libs/auto-config';
autoConfig.deferred = true;
const config = autoConfig({
port: {
args: ['--port', 'PORT'],
required: true,
},
});
Why
Some applications may prefer to delay evaluation of the validation.
Pros
Cons
Dev notes
Possible implementations:
getgetter wrapper object?Considerations
Usage?
Option naming:
deferred: truedelayed: truevalidate: 'delayed',validateOn: 'load' | 'access'Some Examples
1/3: Per Config:
deferredoption2/3:
autoConfigInstance Default3/3: Global Override