// This will correctly set the text black when the file exists, and red when it doesn't
// but the tooltip is _permanently_ "Expected: null" regardless of whether the file exists or not.
// useable with o.datatype = "file"
validation.types.file = function() {
	var self = this;
	if (this.value.length == 0) {
		return true;
	}
	var outcome = fs.stat(this.value).then(function(blob) {
		console.log("statted a blog to", blob);
		if (blob.type == "file") {
			return true;
		}
		return _("Path exists but is not a file");
	}).catch(function(gak) {
		return _("File not found");
	})
	.then(function(msg) {
		var f = L.bind(function(a) {
			console.log("inside final bound", this, self, a);
			return this.assert(a == true, a);   // breaking in validation.js, I see this correctly sets the .error attribute.
		}, self, msg);
		return f();
	});

	console.log("final type file outcome: ", outcome);
	return L.resolveDefault(outcome, "something went bang");
}


/// This attempts to try a "validate" function instead
/// o.validate = valid_file
// console.log will show the expected value, but text is always red,
// and tooltip is always: [object: Promise]
async function valid_file(section, formvalue) {
	var outcome = await fs.stat(formvalue).then(function(blob) {
		console.log("statted a blog to", blob);
		if (blob.type == "file") {
			return true;
		}
		return _("Path exists but is not a file");
	}).catch(function(gak) {
		return _("File not found");
	})
	console.log("final outcome: ", outcome);  // looks good, but... no.
	return L.resolveDefault(outcome, "something went bang");  // trying without await/async and resolving doesn't help...
//	return outcome;
}