{"id":15699019,"url":"https://github.com/pgilad/unquoted-property-validator","last_synced_at":"2025-05-08T22:28:13.661Z","repository":{"id":20136327,"uuid":"23406516","full_name":"pgilad/unquoted-property-validator","owner":"pgilad","description":"Unquoted JavaScript property name validator","archived":false,"fork":false,"pushed_at":"2019-02-13T09:24:19.000Z","size":24,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T09:29:33.621Z","etag":null,"topics":["identifier","javascript","literal","quotes","validation"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgilad.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-27T21:44:15.000Z","updated_at":"2020-05-10T23:02:01.000Z","dependencies_parsed_at":"2022-08-30T10:42:11.351Z","dependency_job_id":null,"html_url":"https://github.com/pgilad/unquoted-property-validator","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgilad%2Funquoted-property-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgilad%2Funquoted-property-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgilad%2Funquoted-property-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgilad%2Funquoted-property-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgilad","download_url":"https://codeload.github.com/pgilad/unquoted-property-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253157020,"owners_count":21863046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["identifier","javascript","literal","quotes","validation"],"created_at":"2024-10-03T19:37:27.845Z","updated_at":"2025-05-08T22:28:13.641Z","avatar_url":"https://github.com/pgilad.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# unquoted-property-validator\n\u003e Unquoted JavaScript property name validator\n\n[![NPM Version](http://img.shields.io/npm/v/unquoted-property-validator.svg?style=flat)](https://npmjs.org/package/unquoted-property-validator)\n[![NPM Downloads](http://img.shields.io/npm/dm/unquoted-property-validator.svg?style=flat)](https://npmjs.org/package/unquoted-property-validator)\n[![Build Status](http://img.shields.io/travis/pgilad/unquoted-property-validator.svg?style=flat)](https://travis-ci.org/pgilad/unquoted-property-validator)\n\nThis module checks if a given property name can be used without quotes and/or with dot notation.\n\nIt is based on Mathias Bynens brilliant [javascript-properties article](https://mathiasbynens.be/notes/javascript-properties).\nSo this is a **node-port** of his [website implementation](https://github.com/mathiasbynens/mothereff.in/tree/master/js-properties).\n\n## Installation\n\n```bash\n$ npm install unquoted-property-validator --save\n```\n\n## Usage\n\n```js\nvar unquotedValidator = require('unquoted-property-validator');\n\nvar results = unquotedValidator('myCoolLiteral');\nconsole.log(results);\n/* {\n    needsQuotes: false,\n    needsBrackets: false,\n    es3Warning: false,\n    quotedValue: 'myCoolLiteral'\n   }\n*/\n```\n\nIn ES6/Typescript the first line should look like this instead:\n\n```js\nimport unquotedValidator = require('unquoted-property-validator');\n```\n\n## Results\n\nYour property input will be checked and you will get 3 flags as output:\n\n### needsQuotes\n\nQuotes can only be omitted if the property name is a numeric literal or a valid identifier name:\n\n```js\nvar obj = {\n        nonQuoted: true,\n        'must-be-quoted' : true\n    };\n```\n\n### needsBrackets\n\nDot notation can only be used when the property name is a valid identifier name:\n\n```js\nobj.bracketFree = true; //use the supreme dot notation\nobj['requires-brackets'] = true; //string must be inside brackets to be used as property\n```\n\n### es3Warning\n\nShould you want to support ES3, you cannot use some identifiers:\n```js\nobj['var'] //-\u003e invalid in ES3\nvar obj = {\n        goto: true //-\u003e invalid in ES3\n    };\n```\n\n### quotedValue\n\nYour quoted string in case there are problematic characters.\n\n## API\n\n`unquotedValidator(input)`\n\n### input\n\nType: `String`\n\nProperty to validate\n\n## License\n\nMIT © [Gilad Peleg](https://www.giladpeleg.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgilad%2Funquoted-property-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgilad%2Funquoted-property-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgilad%2Funquoted-property-validator/lists"}