« get me outta code hell

flag.js « wiki-properties « composite « data « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/wiki-properties/flag.js
blob: 076e663fe1836369db824744b095d4000acb2308 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Straightforward flag descriptor for a variety of property purposes.
// Provide a default value, true or false!

import {isBoolean} from '#validators';

// TODO: Not templateCompositeFrom.

// TODO: The description is a lie. This defaults to false. Bad.

export default function(defaultValue = false) {
  if (typeof defaultValue !== 'boolean') {
    throw new TypeError(`Always set explicit defaults for flags!`);
  }

  return {
    flags: {update: true, expose: true},
    update: {validate: isBoolean, default: defaultValue},
  };
}