Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
checkForErrors = () => {
let hasError = [...this.state.hasError];
const { radioId, noFeedbackId } = this.props;
const { feedbackChoice, formSubmitted } = this.state;
// The user has not selected yes or no.
if (!hasError.includes(radioId) && feedbackChoice === null) {
hasError.push(radioId);
}
if (hasError.includes(radioId) && !is.nil(feedbackChoice)) {
hasError = this.removeError(hasError, radioId);
}
// The user has selected no but has not typed any feedback.
if (!hasError.includes(noFeedbackId) && feedbackChoice === false && formSubmitted && is.empty(this.noTextArea.current.value)) {
hasError.push(noFeedbackId);
} else if (hasError.includes(noFeedbackId) && feedbackChoice === false && !is.empty(this.noTextArea.current.value)) {
hasError = this.removeError(hasError, noFeedbackId);
}
// If the user changed choices from no to yes, remove the error for no if there was one.
if (feedbackChoice === true && hasError.includes(noFeedbackId)) {
hasError = this.removeError(hasError, noFeedbackId);
}
// Prevent calling setState too often while typing in textareas.
if (!is.equal(hasError, this.state.hasError)) {
this.setState({ hasError });
}
return function validator(val) {
const validatorArgs = [val].concat(args)
if ((passIfEmpty && (is.empty(val) || is.nil(val))) || is.undef(val)) {
return true
}
return fn.apply(this, validatorArgs)
}
}
return attrs.reduce((output, value, key) => {
if (is.undef(value) || is.nil(value)) {
return output;
} else if (is.equal(value, '')) {
return `${output} ${key}`;
}
return `${output} ${key}="${escape(value)}"`;
}, '');
}
function convert(schemaField, value) {
if (is.nil(value)) {
return value;
}
switch (schemaField.type) {
case 'BOOLEAN':
case 'BOOL': {
value = value.toLowerCase() === 'true';
break;
}
case 'BYTES': {
value = Buffer.from(value, 'base64');
break;
}
case 'FLOAT':
case 'FLOAT64': {
value = parseFloat(value);
}
if (is.array(val)) {
var encodedElements = [];
for (var i = 0; i < val.length; ++i) {
var enc = encodeHelper(val[i]);
if (enc) {
encodedElements.push(enc);
}
}
return {
arrayValue: {
values: encodedElements,
},
};
}
if (is.nil(val)) {
return {
nullValue: "NULL_VALUE",
};
}
if (is.instanceof(val, Buffer) || is.instanceof(val, Uint8Array)) {
return {
bytesValue: val,
};
}
if (isPlainObject(val)) {
return {
mapValue: {
fields: encodeFirestoreValue(val),
},
};
}
function encodeValue(value) {
var valueProto = {};
if (is.boolean(value)) {
valueProto.booleanValue = value;
return valueProto;
}
if (is.nil(value)) {
valueProto.nullValue = 0;
return valueProto;
}
if (is.number(value)) {
if (value % 1 === 0) {
value = new entity.Int(value);
} else {
value = new entity.Double(value);
}
}
if (isDsInt(value)) {
valueProto.integerValue = value.value;
return valueProto;
}
function convert(schemaField, value) {
if (is.nil(value)) {
return value;
}
switch (schemaField.type) {
case 'BOOLEAN':
case 'BOOL': {
value = value.toLowerCase() === 'true';
break;
}
case 'BYTES': {
value = new Buffer(value, 'base64');
break;
}
case 'FLOAT':
case 'FLOAT64': {
value = parseFloat(value);