yedra 0.12.0 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,12 @@ import { Issue, ValidationError } from './error.js';
2
2
  import { ModifiableSchema } from './modifiable.js';
3
3
  class BooleanSchema extends ModifiableSchema {
4
4
  parse(obj) {
5
+ if (obj === 'true') {
6
+ return true;
7
+ }
8
+ if (obj === 'false') {
9
+ return false;
10
+ }
5
11
  if (typeof obj !== 'boolean') {
6
12
  throw new ValidationError([
7
13
  new Issue('invalidType', [], 'boolean', typeof obj),
@@ -10,7 +10,6 @@ class EnumSchema extends ModifiableSchema {
10
10
  (typeof obj !== 'string' && typeof obj !== 'number') ||
11
11
  !this.options.includes(obj)) {
12
12
  throw new ValidationError([
13
- // TODO: better validation message
14
13
  new Issue('invalidType', [], this.options.join(', '), typeof obj === 'string' || typeof obj === 'number'
15
14
  ? obj.toString()
16
15
  : typeof obj),
@@ -20,9 +19,8 @@ class EnumSchema extends ModifiableSchema {
20
19
  }
21
20
  documentation() {
22
21
  return {
23
- anyOf: this.options.map((option) => ({
24
- const: option,
25
- })),
22
+ type: 'string',
23
+ enum: this.options,
26
24
  };
27
25
  }
28
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yedra",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "repository": "github:0codekit/yedra",
5
5
  "main": "dist/index.js",
6
6
  "devDependencies": {