@sprucelabs/schema
Version:
Static and dynamic binding plus runtime validation and transformation to ensure your app is sound. 🤓
26 lines (25 loc) • 873 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const AbstractField_1 = __importDefault(require("./AbstractField"));
class BooleanField extends AbstractField_1.default {
static generateTemplateDetails(options) {
return {
valueType: `boolean${options.definition.isArray ? '[]' : ''}`,
};
}
/** * Turn everything into a string */
toValueType(value) {
switch (value) {
case 'true':
return true;
case 'false':
return false;
}
return !!value;
}
}
BooleanField.description = 'A true/false. Converts false string to false, all other strings to true.';
exports.default = BooleanField;