ember-headless-form-yup 1.0.0-beta.0 → 1.0.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"validate-yup.js","sources":["../../src/helpers/validate-yup.ts"],"sourcesContent":["import type {\n ErrorRecord,\n FormKey,\n FormValidateCallback,\n} from 'ember-headless-form';\nimport { assert } from '@ember/debug';\n\nimport type { ObjectSchema, ValidationError } from 'yup';\n\n/**\n * Validation helper for integrating `yup` based validations into headless forms.\n *\n * Pass this to the `@validate` hook, supplying the `yup` schema as the only argument: `@validate={{validateYup schema}}`.\n */\nexport default function validateChangeset<DATA extends object>(\n schema: ObjectSchema<DATA>\n): FormValidateCallback<Partial<DATA>> {\n return async (formData) => {\n try {\n await schema.validate(formData, { abortEarly: false });\n } catch (e) {\n const validationError = e as ValidationError;\n const errorRecord: ErrorRecord<DATA> = {};\n\n for (const { path, type, value, message } of validationError.inner) {\n assert(\n 'Received undefined path for yup validation error. If you see this, please report it as a bug to ember-headless-form!',\n path !== undefined\n );\n const key = path as FormKey<DATA>; // yup maybe could have stricter types here, as path will always refer to a key of its schema\n\n if (!errorRecord[key]) {\n errorRecord[key] = [];\n }\n\n const errors = errorRecord[key];\n assert('Expected errorRecord to have array', errors); // TS does not understand errors cannot be undefined at this point\n\n errors.push({\n type: type ?? 'unknown',\n value,\n message,\n });\n }\n\n return errorRecord;\n }\n\n return undefined;\n };\n}\n"],"names":["validateChangeset","schema","formData","validate","abortEarly","e","validationError","errorRecord","path","type","value","message","inner","assert","undefined","key","errors","push"],"mappings":";;AASA;AACA;AACA;AACA;AACA;AACe,SAASA,iBAAiB,CACvCC,MAA0B,EACW;EACrC,OAAO,MAAOC,QAAQ,IAAK;IACzB,IAAI;AACF,MAAA,MAAMD,MAAM,CAACE,QAAQ,CAACD,QAAQ,EAAE;AAAEE,QAAAA,UAAU,EAAE,KAAA;AAAM,OAAC,CAAC,CAAA;KACvD,CAAC,OAAOC,CAAC,EAAE;MACV,MAAMC,eAAe,GAAGD,CAAoB,CAAA;MAC5C,MAAME,WAA8B,GAAG,EAAE,CAAA;AAEzC,MAAA,KAAK,MAAM;QAAEC,IAAI;QAAEC,IAAI;QAAEC,KAAK;AAAEC,QAAAA,OAAAA;AAAQ,OAAC,IAAIL,eAAe,CAACM,KAAK,EAAE;AAClEC,QAAAA,MAAM,CACJ,sHAAsH,EACtHL,IAAI,KAAKM,SAAS,CACnB,CAAA;AACD,QAAA,MAAMC,GAAG,GAAGP,IAAqB,CAAC;;AAElC,QAAA,IAAI,CAACD,WAAW,CAACQ,GAAG,CAAC,EAAE;AACrBR,UAAAA,WAAW,CAACQ,GAAG,CAAC,GAAG,EAAE,CAAA;AACvB,SAAA;AAEA,QAAA,MAAMC,MAAM,GAAGT,WAAW,CAACQ,GAAG,CAAC,CAAA;AAC/BF,QAAAA,MAAM,CAAC,oCAAoC,EAAEG,MAAM,CAAC,CAAC;;QAErDA,MAAM,CAACC,IAAI,CAAC;UACVR,IAAI,EAAEA,IAAI,IAAI,SAAS;UACvBC,KAAK;AACLC,UAAAA,OAAAA;AACF,SAAC,CAAC,CAAA;AACJ,OAAA;AAEA,MAAA,OAAOJ,WAAW,CAAA;AACpB,KAAA;AAEA,IAAA,OAAOO,SAAS,CAAA;GACjB,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"validate-yup.js","sources":["../../src/helpers/validate-yup.ts"],"sourcesContent":["import type {\n ErrorRecord,\n FormKey,\n FormValidateCallback,\n} from 'ember-headless-form';\nimport { assert } from '@ember/debug';\n\nimport type { ObjectSchema, ValidationError } from 'yup';\n\n/**\n * Validation helper for integrating `yup` based validations into headless forms.\n *\n * Pass this to the `@validate` hook, supplying the `yup` schema as the only argument: `@validate={{validateYup schema}}`.\n */\nexport default function validateChangeset<DATA extends object>(\n schema: ObjectSchema<DATA>\n): FormValidateCallback<Partial<DATA>> {\n return async (formData) => {\n try {\n await schema.validate(formData, { abortEarly: false });\n } catch (e) {\n const validationError = e as ValidationError;\n const errorRecord: ErrorRecord<DATA> = {};\n\n for (const { path, type, value, message } of validationError.inner) {\n assert(\n 'Received undefined path for yup validation error. If you see this, please report it as a bug to ember-headless-form!',\n path !== undefined\n );\n const key = path as FormKey<DATA>; // yup maybe could have stricter types here, as path will always refer to a key of its schema\n\n if (!errorRecord[key]) {\n errorRecord[key] = [];\n }\n\n const errors = errorRecord[key];\n assert('Expected errorRecord to have array', errors); // TS does not understand errors cannot be undefined at this point\n\n errors.push({\n type: type ?? 'unknown',\n value,\n message,\n });\n }\n\n return errorRecord;\n }\n\n return undefined;\n };\n}\n"],"names":["validateChangeset","schema","formData","validate","abortEarly","e","validationError","errorRecord","path","type","value","message","inner","assert","undefined","key","errors","push"],"mappings":";;AASA;AACA;AACA;AACA;AACA;AACe,SAASA,iBAAiBA,CACvCC,MAA0B,EACW;EACrC,OAAO,MAAOC,QAAQ,IAAK;IACzB,IAAI;AACF,MAAA,MAAMD,MAAM,CAACE,QAAQ,CAACD,QAAQ,EAAE;AAAEE,QAAAA,UAAU,EAAE,KAAA;AAAM,OAAC,CAAC,CAAA;KACvD,CAAC,OAAOC,CAAC,EAAE;MACV,MAAMC,eAAe,GAAGD,CAAoB,CAAA;MAC5C,MAAME,WAA8B,GAAG,EAAE,CAAA;AAEzC,MAAA,KAAK,MAAM;QAAEC,IAAI;QAAEC,IAAI;QAAEC,KAAK;AAAEC,QAAAA,OAAAA;AAAQ,OAAC,IAAIL,eAAe,CAACM,KAAK,EAAE;AAClEC,QAAAA,MAAM,CACJ,sHAAsH,EACtHL,IAAI,KAAKM,SACX,CAAC,CAAA;AACD,QAAA,MAAMC,GAAG,GAAGP,IAAqB,CAAC;;AAElC,QAAA,IAAI,CAACD,WAAW,CAACQ,GAAG,CAAC,EAAE;AACrBR,UAAAA,WAAW,CAACQ,GAAG,CAAC,GAAG,EAAE,CAAA;AACvB,SAAA;AAEA,QAAA,MAAMC,MAAM,GAAGT,WAAW,CAACQ,GAAG,CAAC,CAAA;AAC/BF,QAAAA,MAAM,CAAC,oCAAoC,EAAEG,MAAM,CAAC,CAAC;;QAErDA,MAAM,CAACC,IAAI,CAAC;UACVR,IAAI,EAAEA,IAAI,IAAI,SAAS;UACvBC,KAAK;AACLC,UAAAA,OAAAA;AACF,SAAC,CAAC,CAAA;AACJ,OAAA;AAEA,MAAA,OAAOJ,WAAW,CAAA;AACpB,KAAA;AAEA,IAAA,OAAOO,SAAS,CAAA;GACjB,CAAA;AACH;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-headless-form-yup",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0",
4
4
  "description": "Integrates yup-based validations with ember-headless-form",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -14,26 +14,26 @@
14
14
  ],
15
15
  "dependencies": {
16
16
  "@embroider/addon-shim": "^1.0.0",
17
- "ember-functions-as-helper-polyfill": "^2.1.1"
17
+ "ember-functions-as-helper-polyfill": "^2.1.2"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "yup": "^1.0.0",
21
- "ember-headless-form": "^1.0.0-beta.0",
21
+ "ember-headless-form": "^1.0.0",
22
22
  "ember-source": ">=4.4.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@babel/core": "^7.17.0",
26
- "@babel/preset-typescript": "^7.18.6",
27
- "@babel/plugin-proposal-class-properties": "^7.16.7",
28
- "@babel/plugin-proposal-decorators": "^7.17.0",
29
- "@babel/plugin-syntax-decorators": "^7.17.0",
30
- "ember-headless-form": "^1.0.0-beta.0",
31
- "@embroider/addon-dev": "^3.0.0",
25
+ "@babel/core": "^7.23.6",
26
+ "@babel/preset-typescript": "^7.23.3",
27
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
28
+ "@babel/plugin-proposal-decorators": "^7.23.6",
29
+ "@babel/plugin-syntax-decorators": "^7.23.3",
30
+ "ember-headless-form": "^1.0.0",
31
+ "@embroider/addon-dev": "^4.0.0",
32
32
  "@glimmer/component": "^1.1.2",
33
- "@glint/core": "^1.0.0-beta.3",
34
- "@glint/environment-ember-loose": "^1.0.0-beta.3",
35
- "@glint/template": "^1.0.0-beta.3",
36
- "@tsconfig/ember": "^1.0.0",
33
+ "@glint/core": "^1.0.2",
34
+ "@glint/environment-ember-loose": "^1.0.2",
35
+ "@glint/template": "^1.0.2",
36
+ "@tsconfig/ember": "^2.0.0",
37
37
  "@types/ember": "^4.0.0",
38
38
  "@types/ember__object": "^4.0.0",
39
39
  "@types/ember__service": "^4.0.0",
@@ -53,19 +53,19 @@
53
53
  "@types/ember__routing": "^4.0.0",
54
54
  "@typescript-eslint/eslint-plugin": "^5.30.5",
55
55
  "@typescript-eslint/parser": "^5.30.5",
56
- "concurrently": "^7.2.1",
56
+ "concurrently": "^8.0.0",
57
57
  "ember-template-lint": "^4.0.0",
58
- "ember-source": "~4.10.0",
58
+ "ember-source": "~5.5.0",
59
59
  "eslint": "^7.32.0",
60
60
  "eslint-config-prettier": "^8.3.0",
61
- "eslint-plugin-ember": "^10.5.8",
61
+ "eslint-plugin-ember": "^11.9.0",
62
62
  "eslint-plugin-node": "^11.1.0",
63
63
  "eslint-plugin-prettier": "^4.0.0",
64
64
  "prettier": "^2.5.1",
65
- "rollup": "^2.67.0",
65
+ "rollup": "^4.0.0",
66
66
  "rollup-plugin-copy": "^3.4.0",
67
67
  "rollup-plugin-ts": "^3.0.2",
68
- "typescript": "^4.7.4",
68
+ "typescript": "^5.0.0",
69
69
  "yup": "^1.0.0",
70
70
  "webpack": "^5.75.0"
71
71
  },
@@ -98,6 +98,9 @@
98
98
  ]
99
99
  }
100
100
  },
101
+ "volta": {
102
+ "extends": "../../package.json"
103
+ },
101
104
  "scripts": {
102
105
  "build": "rollup --config",
103
106
  "lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",