{"_id":"@voscausa/svelte-use-validate","_rev":"33-d829d4a041c9e7694a119a94ca31998c","time":{"created":"2023-04-25T05:07:30.322Z","1.0.2":"2021-11-03T20:01:16.758Z","modified":"2024-01-18T12:11:53.067Z","1.0.3":"2021-11-03T20:23:04.434Z","1.0.4":"2021-11-04T00:02:58.832Z","1.0.5":"2021-11-04T00:35:21.242Z","1.0.6":"2021-11-04T02:04:41.068Z","1.0.7":"2021-11-04T03:12:52.367Z","1.0.8":"2021-11-04T03:23:57.580Z","1.0.9":"2021-11-04T12:09:23.196Z","1.1.0":"2021-11-04T12:28:13.994Z","1.1.1":"2021-11-04T16:13:41.619Z","1.1.2":"2021-11-04T18:38:59.633Z","1.1.3":"2021-11-04T18:46:04.911Z","1.1.4":"2021-11-04T21:42:52.526Z","1.1.5":"2021-11-05T00:11:43.730Z","1.1.6":"2021-11-05T16:10:08.681Z","1.1.7":"2021-11-05T23:01:19.307Z","1.1.8":"2021-11-07T11:56:44.130Z","1.1.9":"2021-11-07T13:58:12.406Z","1.2.0":"2021-11-07T14:13:05.287Z","1.2.1":"2021-11-07T14:23:09.064Z","1.2.2":"2021-11-07T17:38:53.161Z","1.3.0":"2022-01-01T22:25:14.319Z","1.3.1":"2022-01-01T22:28:41.967Z","1.3.2":"2022-01-01T22:34:25.467Z","1.3.3":"2022-01-02T09:03:02.234Z","1.3.4":"2022-01-02T09:05:43.055Z","1.4.0":"2023-04-25T05:07:30.622Z","1.4.1":"2023-09-17T06:36:13.989Z","1.4.2":"2023-09-17T06:46:25.010Z","1.4.3":"2023-10-02T06:46:39.418Z","1.4.4":"2023-11-09T17:59:07.158Z","1.4.8":"2024-01-18T12:11:52.890Z"},"name":"@voscausa/svelte-use-validate","dist-tags":{"latest":"1.4.8"},"versions":{"1.4.0":{"name":"@voscausa/svelte-use-validate","version":"1.4.0","description":"A Svelte use:action to validate inputs","main":"./dist/index.js","exports":"./dist/index.js","author":{"name":"voscausa"},"keywords":["svelte","actions","forms","inputs","validate","validator","svelte form validation","svelte use:action"],"license":"MIT","type":"module","repository":{"type":"git","url":"git+https://github.com/voscausa/svelte-use-validate.git"},"homepage":"https://github.com/voscausa/svelte-use-validate#readme","scripts":{},"devDependencies":{},"gitHead":"a408228e81a9c1f6413e466d1e741cb1f6bfcd9b","bugs":{"url":"https://github.com/voscausa/svelte-use-validate/issues"},"_id":"@voscausa/svelte-use-validate@1.4.0","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-wAB+Uk2tQbDFnfyLDGrzAXz+/4sNnMElWPHjKpgxg2L9Gp7Ty1ihw8kvhsy2qf2VxFa4N7nvyQvGRbsmRqZT0w==","shasum":"2c9616fa91691b10e0b9f0787c43723875daf879","tarball":"https://registry.npmjs.org/@voscausa/svelte-use-validate/-/svelte-use-validate-1.4.0.tgz","fileCount":6,"unpackedSize":15305,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICwocp6GcE9AI6oyMXJxUOi+9Fy5O2HWtPG6/L2hH4bgAiEAnYOJeFdmT+kXpYms4l7aABmsVLBzds/uJ5UOXXOPo5Y="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkR2ASACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqc8w//Sytn2VlcnFRlYsWOg4tDsCPDdq9zQC3UmpueGgs8apH9NhQ5\r\ntUicAzBOsQRjjy/Hq3OirSFWihnVG28xqbZM0ahQmIjsIjSKwYgKq6IR+hNc\r\nd7PmXaxUaHQs2w9pNjbZnFDi3UqA5i7nnUusWK6kPn5kpGylJjKozoQMzr6H\r\nwuX+dEQyaAqZDr3wwmBFPeQqkdtUsOPa/juU2R9I/UWrVrfelIddhMkzSj+I\r\nku3d0UczyDSuK8Qeim7aev875T9u6hD2ekMlIEr8WapdtfhIVJNdPVrCyEje\r\nQwEiBr824C+8mnHFte3HCUv985itxXdm77gfe5DBcDFPx6zk+63ZgmSbezCj\r\ne6WUfwrPCRFEv/qoZn8m/1P1h7esowqQII7CgRVDqV4J8lLv+ZNXHDH1TZvO\r\nTTe6ATm0lLsjdAc14uZg9mgrPQAuOClgIIw7GSb4MhwOBNqjsaah/7EV1VZL\r\nPAlnyFahwK4lFl2OjMjhwHHt52/5wb+E4pseg8ckOltndQzfyjTu6ih4B6CB\r\n2pembs+PqoFzu6NT3pn0w1F8Z63tS2sZELHk+PfMpviFyQPLrQ0jImPY3yNH\r\nyjSIdGLpbJb+99qDUHaEtPY4swbFoZVapWZuufldixrurefYz3Lwsg+xcWwL\r\nqB8DsWUUFh/A36nAM0/er6GbxOvr89sRxT0=\r\n=Q2sz\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"voscausa","email":"robert.vos@gmail.com"},"directories":{},"maintainers":[{"name":"voscausa","email":"robert.vos@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-use-validate_1.4.0_1682399250400_0.5359061028303427"},"_hasShrinkwrap":false},"1.4.1":{"name":"@voscausa/svelte-use-validate","version":"1.4.1","description":"A Svelte use:action to validate inputs","main":"./dist/index.js","exports":"./dist/index.js","author":{"name":"voscausa"},"keywords":["svelte","actions","forms","inputs","validate","validator","svelte form validation","svelte use:action"],"license":"MIT","type":"module","repository":{"type":"git","url":"git+https://github.com/voscausa/svelte-use-validate.git"},"homepage":"https://github.com/voscausa/svelte-use-validate#readme","scripts":{},"devDependencies":{},"gitHead":"023e10051f029d93263a7d34501f818135a5e019","bugs":{"url":"https://github.com/voscausa/svelte-use-validate/issues"},"_id":"@voscausa/svelte-use-validate@1.4.1","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-wj84HfbQ1pgMrsteKlG3do9UQ46/ggAd604BfBUnSu/Na3W2TG7ogPgervk3AjqkaCPScbYP3IfsYzuAnieClQ==","shasum":"1d4cd9b181e974932eaf78e439cc8ae5ab658e06","tarball":"https://registry.npmjs.org/@voscausa/svelte-use-validate/-/svelte-use-validate-1.4.1.tgz","fileCount":6,"unpackedSize":15441,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDH9MVSNVegKplnhjMsox45uqBlbvN9829NK9yISNZe9AIhALcgsh9SNx76xVmjcL4w+pg6jF9rZO086pGETEiCHmd1"}]},"_npmUser":{"name":"voscausa","email":"robert.vos@gmail.com"},"directories":{},"maintainers":[{"name":"voscausa","email":"robert.vos@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-use-validate_1.4.1_1694932573765_0.020475178316561093"},"_hasShrinkwrap":false},"1.4.2":{"name":"@voscausa/svelte-use-validate","version":"1.4.2","description":"A Svelte use:action to validate inputs","main":"./dist/index.js","exports":"./dist/index.js","author":{"name":"voscausa"},"keywords":["svelte","actions","forms","inputs","validate","validator","svelte form validation","svelte use:action"],"license":"MIT","type":"module","repository":{"type":"git","url":"git+https://github.com/voscausa/svelte-use-validate.git"},"homepage":"https://github.com/voscausa/svelte-use-validate#readme","scripts":{},"devDependencies":{},"gitHead":"e06427793ea39a53700df6489c77ff7bc3e2ddc2","bugs":{"url":"https://github.com/voscausa/svelte-use-validate/issues"},"_id":"@voscausa/svelte-use-validate@1.4.2","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-3nXb5is7/WSErIsDZMQrfykFmr2u98/KUD4upEkbIT38BgKWzAqB/HcyfrWpSRu9IAYTv2OFjhhwt+DUlDorUg==","shasum":"0f8b60d16d49b48290646c60aea38ed9701d7bc9","tarball":"https://registry.npmjs.org/@voscausa/svelte-use-validate/-/svelte-use-validate-1.4.2.tgz","fileCount":6,"unpackedSize":15473,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGTf/geYeMMj5IwFuLESiP2Jdh3jEEQ8OlWA5u8p+qDxAiB5bu2SX+cQA7NPSN/XrmuxCUJ6CMt+HTuxutMwVY87WA=="}]},"_npmUser":{"name":"voscausa","email":"robert.vos@gmail.com"},"directories":{},"maintainers":[{"name":"voscausa","email":"robert.vos@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-use-validate_1.4.2_1694933184798_0.7754060739742503"},"_hasShrinkwrap":false},"1.4.3":{"name":"@voscausa/svelte-use-validate","version":"1.4.3","description":"A Svelte use:action to validate inputs","main":"./dist/index.js","exports":"./dist/index.js","author":{"name":"voscausa"},"keywords":["svelte","actions","forms","inputs","validate","validator","svelte form validation","svelte use:action"],"license":"MIT","type":"module","repository":{"type":"git","url":"git+https://github.com/voscausa/svelte-use-validate.git"},"homepage":"https://github.com/voscausa/svelte-use-validate#readme","scripts":{},"devDependencies":{},"gitHead":"b44219fb7c4996ef564c68a034ee74e82cf90f0b","bugs":{"url":"https://github.com/voscausa/svelte-use-validate/issues"},"_id":"@voscausa/svelte-use-validate@1.4.3","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-Mwygee3hGxB4quY5sHwprpT67aRBy9epB/j3lz3Rmor7UoZFT/TlXQdvKEb0PvQwYywniiA2HovfBguQxruRbA==","shasum":"5ff7359905b4ce512cb66498ec5f60108dcf9ed7","tarball":"https://registry.npmjs.org/@voscausa/svelte-use-validate/-/svelte-use-validate-1.4.3.tgz","fileCount":6,"unpackedSize":15541,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAKJeBQC/N4LdwrSNsbj8lb5Dx99HPT+lOTieI10w/grAiAKUy+4tmcPgbujXbuY2mZQLVFBLwzba24AYFHsMM7N3w=="}]},"_npmUser":{"name":"voscausa","email":"robert.vos@gmail.com"},"directories":{},"maintainers":[{"name":"voscausa","email":"robert.vos@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-use-validate_1.4.3_1696229199252_0.6138922474785677"},"_hasShrinkwrap":false},"1.4.4":{"name":"@voscausa/svelte-use-validate","version":"1.4.4","description":"A Svelte use:action to validate inputs","main":"./dist/index.js","exports":"./dist/index.js","author":{"name":"voscausa"},"keywords":["svelte","actions","forms","inputs","validate","validator","svelte form validation","svelte use:action"],"license":"MIT","type":"module","repository":{"type":"git","url":"git+https://github.com/voscausa/svelte-use-validate.git"},"homepage":"https://github.com/voscausa/svelte-use-validate#readme","scripts":{},"devDependencies":{},"gitHead":"8be1089280b8b727c06d2cc65e156505f708a963","bugs":{"url":"https://github.com/voscausa/svelte-use-validate/issues"},"_id":"@voscausa/svelte-use-validate@1.4.4","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-2VtzIypUcbcHsZ8BkG0672iFm1s+qM41ADU3Z7Acz+b6nO6/cOHFApPtPkhPeAXHGAZvg98aRhELdON3PSblfg==","shasum":"213312d3a34125968c36e96e6b42845dc00296f5","tarball":"https://registry.npmjs.org/@voscausa/svelte-use-validate/-/svelte-use-validate-1.4.4.tgz","fileCount":6,"unpackedSize":15631,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDNlYImMC4x0+mWP3RGgAg+XQyeO3a+vZnAibuECSz/QgIgXL32eOXkcgNq6KrbEt3tm8U91ROTvJzx9Fo+F8s8HVk="}]},"_npmUser":{"name":"voscausa","email":"robert.vos@gmail.com"},"directories":{},"maintainers":[{"name":"voscausa","email":"robert.vos@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-use-validate_1.4.4_1699552746926_0.1397831622956074"},"_hasShrinkwrap":false},"1.4.8":{"name":"@voscausa/svelte-use-validate","version":"1.4.8","description":"A Svelte use:action to validate inputs","main":"./dist/index.js","exports":"./dist/index.js","author":{"name":"voscausa"},"keywords":["svelte","actions","forms","inputs","validate","validator","svelte form validation","svelte use:action"],"license":"MIT","type":"module","repository":{"type":"git","url":"git+https://github.com/voscausa/svelte-use-validate.git"},"homepage":"https://github.com/voscausa/svelte-use-validate#readme","scripts":{},"devDependencies":{},"gitHead":"32a3d444708f3ddddd58033327ce5c40bea95867","bugs":{"url":"https://github.com/voscausa/svelte-use-validate/issues"},"_id":"@voscausa/svelte-use-validate@1.4.8","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-4kE5k+vzYds0U/0NcC0nhr7Bi7hZjjuz32SPvgzxjZtEuyXVbPt30GnYV66CyJwsClHEJUhAk2f5PxzK1lQeDQ==","shasum":"dea338163ccb2e9fe925c4d8df5b643b2c085c9c","tarball":"https://registry.npmjs.org/@voscausa/svelte-use-validate/-/svelte-use-validate-1.4.8.tgz","fileCount":6,"unpackedSize":15754,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDORhRjSxXLFruDinPBEcr0EPjGpmRsW+aHHjuSGs/h7wIhAPOzCWHyk2AWBVALsn+5WWDVE2HbHepG9ARt9ZeM5Gze"}]},"_npmUser":{"name":"voscausa","email":"robert.vos@gmail.com"},"directories":{},"maintainers":[{"name":"voscausa","email":"robert.vos@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-use-validate_1.4.8_1705579912659_0.6096447391867064"},"_hasShrinkwrap":false}},"maintainers":[{"name":"voscausa","email":"robert.vos@gmail.com"}],"description":"A Svelte use:action to validate inputs","homepage":"https://github.com/voscausa/svelte-use-validate#readme","keywords":["svelte","actions","forms","inputs","validate","validator","svelte form validation","svelte use:action"],"repository":{"type":"git","url":"git+https://github.com/voscausa/svelte-use-validate.git"},"author":{"name":"voscausa"},"bugs":{"url":"https://github.com/voscausa/svelte-use-validate/issues"},"license":"MIT","readme":"# svelte-use-validate\r\n\r\n### <b>Features</b>\r\n* html inputs and svelte component validation\r\n* keystroke reactive and optional reactive updates\r\n* validation rules and rule chaining\r\n* lazy validation (on first use) and OK (validate all)\r\n* tooltip like messages and invalid field border markers\r\n* dynamic rulechains (update rules and optional rules)\r\n* add custom validators and cross field validators\r\n* validator controls to control validator behaviour\r\n\r\n### <b>Installation</b>\r\n```\r\nnpm install -D @voscausa/svelte-use-validate\r\n```\r\n\r\n### <b>Config example</b>\r\n\r\n```js\r\n// rulesConfig = { node.id: rule or [rulechain ...], ...}\r\nconst rulesConfig = {\r\n  day: [\"required\", { range: { min: 1, max: 31 } }, \"dayOk\"],\r\n  month: [\"required\", { range: { min: 1, max: 12 } }],\r\n  grossValue: [\"required\", \"cents\"],\r\n  section: [\"required\", \"sectionContra\"], // optional contra\r\n  contra: \"get\", // get default: \"\" if section has no contra\r\n  note: \"get\",\r\n  account_number: [\"required\", \"ibanNum\"], // alt rule with ibanRuleChains(iban)\r\n  iban: \"ibanType\", // alt rule with ibanRuleChains(iban)\r\n  title: [\"required\", { len: { operator: \">=\", len: 10, msg: \"length must be >= 10\" } }],\r\n};\r\n```\r\n\r\n### <b>Initialize validation instance</b>\r\n\r\n```js\r\nimport { validate } from \"@voscausa/svelte-use-validate\";\r\n\r\n// not valid markers for components\r\nconst notValidMarkers = { contra: false, section: false, grossValue: false };\r\n\r\nconst { field, OK, addValidator, fieldValues, runRuleChain } = validate(\r\n  { rulesConfig, lazy: true, markDefault: 3 , alertBelow: 0, setNotValid},\r\n  (id, notValid, value) => {\r\n    // callback to update bindings or signal notValid components\r\n    if (id in notValidMarkers) notValidMarkers[id] = notValid;\r\n  }\r\n);\r\n```\r\nValidate instance config options:\r\n* rulesConfig : rulesConfig object\r\n* lazy : validate on first use (default: ```true```)\r\n* OK() : check all rules (check all before submit)\r\n* addValidator : add a custom validator\r\n* markDefault : mark invalid inputs:\r\n  * 1 : input border only\r\n  * 2 : message below the input only\r\n  * 3 : both border and message\r\n  * 0 : do not mark invalid inputs\r\n* alertBelow : position (in pics) of the alert msg below the input (default: ```0```)\r\n* setNotValid : optional custom validator helper function to mark invalid fields    \r\n\r\n\r\n### <b>Validator funtions</b>\r\n\r\nValidator functions have two types of arguments:\r\n* configured rule arguments like min, max, len, msg and so on\r\n* the field context (this)\r\n  * id: field id, default: ```node.name``` (a unique id for an html element)\r\n  * node: the html element\r\n  * value: the field value\r\n  * controls: array of values to (cross) control the behaviour of the validator\r\n  * mark: field has to be marked with border and or text (default: ```3```)\r\n\r\nA validator returns notValid (true or false). True breaks the rule chain.  \r\n\r\n### <b>Svelte use action field function arguments and defaults</b>\r\n```js\r\nuse:field={value} or use:field={obj}\r\n// where the value / obj argument will be decomposed as show below:\r\nlet { value, id = node.name, mark = 3, controls = [] } = obj;    \r\n```\r\n\r\n### <b>Dynamic rule chaines and cross field validation</b>\r\n\r\n```js\r\n// alt rulechain selection to validate an account_number\r\naddValidator(\"ibanType\", function () {\r\n  runRuleChain.account_number(\r\n    // here we use the iban bool as a control\r\n    this.value\r\n      ? [\"required\", \"ibanNum\"]\r\n      : [\"required\", { len: { operator: \">=\", len: 3, msg: \"not IBAN; length must be > 3\" } }]\r\n  );\r\n  // this iban validator is always OK, return false (bool always OK)\r\n  return false;\r\n});\r\n```\r\n\r\n```js\r\n// alt rulechain selection to validate an optional contra\r\naddValidator(\"sectionContra\", function () {\r\n  runRuleChain.contra(\r\n    // hasContra control => require a contra account input\r\n    this.controls[0]\r\n      ? [\"required\", { func: { fn: validContraSection, msg: \"contra section missing\" } }]\r\n      : \"get\" // no contra account => contra account = \"\"\r\n  );\r\n  // this section validator is always OK, so return false\r\n  return false;\r\n});\r\n```\r\n\r\n### <b>Examples</b>\r\n\r\nAn example Svelte SPA can be found here: [voscausa/use-validate-example](https://github.com/voscausa/use-validate-example)\r\n\r\n![use-validate example form](./example%20form.png)\r\n","readmeFilename":"README.md"}