mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-23 04:25:21 +08:00
# Conflicts: # jsowell-ui/.env.development # jsowell-ui/.env.staging # jsowell-ui/bin/build-sit.bat # jsowell-ui/bin/build.bat # jsowell-ui/src/api/adapayMember/adapayMember.js # jsowell-ui/src/api/pile/merchant.js # jsowell-ui/src/router/index.js # jsowell-ui/src/views/financial/financeDetail.vue # jsowell-ui/src/views/financial/merchant.vue # jsowell-ui/src/views/homeIndex/homeIndex.vue # jsowell-ui/src/views/login.vue # jsowell-ui/src/views/pile/basic/detail.vue # jsowell-ui/src/views/pile/station/components/SiteInfo.vue # jsowell-ui/src/views/pile/station/detail.vue # jsowell-ui/src/views/pile/station/orderReport.vue
50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const Hoek = require('@hapi/hoek');
|
|
|
|
|
|
const internals = {};
|
|
|
|
|
|
exports.create = function (key, options) {
|
|
|
|
Hoek.assert(typeof key === 'string', 'Invalid reference key:', key);
|
|
|
|
const settings = Hoek.clone(options); // options can be reused and modified
|
|
|
|
const ref = function (value, validationOptions) {
|
|
|
|
return Hoek.reach(ref.isContext ? validationOptions.context : value, ref.key, settings);
|
|
};
|
|
|
|
ref.isContext = (key[0] === ((settings && settings.contextPrefix) || '$'));
|
|
ref.key = (ref.isContext ? key.slice(1) : key);
|
|
ref.path = ref.key.split((settings && settings.separator) || '.');
|
|
ref.depth = ref.path.length;
|
|
ref.root = ref.path[0];
|
|
ref.isJoi = true;
|
|
|
|
ref.toString = function () {
|
|
|
|
return (ref.isContext ? 'context:' : 'ref:') + ref.key;
|
|
};
|
|
|
|
return ref;
|
|
};
|
|
|
|
|
|
exports.isRef = function (ref) {
|
|
|
|
return typeof ref === 'function' && ref.isJoi;
|
|
};
|
|
|
|
|
|
exports.push = function (array, ref) {
|
|
|
|
if (exports.isRef(ref) &&
|
|
!ref.isContext) {
|
|
|
|
array.push(ref.root);
|
|
}
|
|
};
|