Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
validate( path, input) {
// The state is updated by widgets, but isn't always synchronous so we check _pendingState first
var state = this._pendingState || this.state
// `reach()` pulls out a child schema so we can test a single path
var field = yup.reach(schema, path)
// we also need the specific value for this path
var value = getter(path)(state);
return field.validate(value, { strict: true })
.then(() => void 0) // if valid return nothing
.catch(err => err.errors) // if invalid return the errors for this field
},
jrefs.get_json_pointer = function(ref, root) {
var evalstr, result
evalstr = ref.replace(/\\\//, '#SLASH#').replace(/\//g, '.').replace(/#SLASH#/, '/')
evalstr = evalstr.replace(new RegExp('^' + jrefs.pathtoken), '')
if (evalstr[0] === '.') {
evalstr = evalstr.substr(1, evalstr.length - 1)
}
try {
if (jrefs.debug) {
console.log("evaluating '" + evalstr + "'")
}
result = expr.getter(evalstr)(root)
} catch (error) {
console.error(error)
result = ''
}
return result
}
jrefs.replace = function(json, ids, root) {
from(from, to, alias) {
let fromGetter = getter(from, true);
return this.transform(obj => {
if (obj == null) return obj;
let newObj = obj;
if (has(obj, from)) {
newObj = { ...obj };
if (!alias) delete newObj[from];
newObj[to] = fromGetter(obj);
}
return newObj;
});
},
Object.keys(mapValue).forEach(key => {
let field = mapValue[key]
let value
if (typeof field === 'function') value = field(...args)
else if (field === '.' || field == null || args[0] == null)
value = args[0]
else {
value = expr.getter(field, true)(args[0])
}
if (paths.indexOf(key) === -1) paths.push(key)
model = setter!(key, model, value, defaultSetter)
})
onChange(model!, paths)
this.validator = new Validator(name => {
var validations = rules[name] || []
, value = getter(name)(this.state)
, error;
var valid = validations.every(({ rule, message }) => {
var valid = rule(value)
if (!valid) error = message
return valid
})
return error
})
}
itemstr = k.replace(/(\{)(.*?)(\})/g, function($0, $1, $2) {
var result
result = ''
if ((data == null) || ($2 == null)) {
return result
}
if ((data[$2] != null) && typeof data[$2] === 'function') {
result = data[$2]()
} else {
if (data[$2] != null) {
result = data[$2]
} else {
try {
$2 = $2.replace(new RegExp('^' + jrefs.pathtoken + '\/'), '').replace(/\//g, '.')
result = expr.getter($2)(data)
} catch (error1) {
err = error1
result = ''
}
if (result == null) {
result = ''
}
}
}
jrefs.evaluateStr(result, data)
return result
})
return itemstr
_classCallCheck(this, Ref);
validateName(key);
var prefix = options.contextPrefix || '$';
if (typeof key === 'function') {
key = '.';
}
this.key = key.trim();
this.prefix = prefix;
this.isContext = this.key.indexOf(prefix) === 0;
this.isSelf = this.key === '.';
this.path = this.isContext ? this.key.slice(this.prefix.length) : this.key;
this._get = getter(this.path, true);
this.map = mapFn || function (value) {
return value;
};
}
getter: (path, model) =>
path ? expr.getter(path, true)(model || {}) : model,
setter: defaultSetter,
return str.replace(strReg, function (_, key) {
return expr.getter(key)(obj) || "";
});
};
this.validator = new Validator(name => {
var validations = rules[name] || []
, value = getter(name)(this.state)
, error;
var valid = validations.every(({ rule, message }) => {
var valid = rule(value)
if (!valid) error = message
return valid
})
return error
})
}