@sprucelabs/schema
Version:
Static and dynamic binding plus runtime validation and transformation to ensure your app is sound. 🤓
21 lines (20 loc) • 623 B
JavaScript
import AbstractField from './AbstractField.js';
class BooleanField extends AbstractField {
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.';
export default BooleanField;