141 lines
6.6 KiB
JSON
141 lines
6.6 KiB
JSON
{
|
|
"_args": [
|
|
[
|
|
{
|
|
"raw": "@expo/schemer@1.1.0",
|
|
"scope": "@expo",
|
|
"escapedName": "@expo%2fschemer",
|
|
"name": "@expo/schemer",
|
|
"rawSpec": "1.1.0",
|
|
"spec": "1.1.0",
|
|
"type": "version"
|
|
},
|
|
"/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/xdl"
|
|
]
|
|
],
|
|
"_from": "@expo/schemer@1.1.0",
|
|
"_id": "@expo/schemer@1.1.0",
|
|
"_inCache": true,
|
|
"_location": "/@expo/schemer",
|
|
"_nodeVersion": "8.5.0",
|
|
"_npmOperationalInternal": {
|
|
"host": "s3://npm-registry-packages",
|
|
"tmp": "tmp/schemer-1.1.0.tgz_1507143724249_0.8371291058138013"
|
|
},
|
|
"_npmUser": {
|
|
"name": "skevy",
|
|
"email": "adam@sk3vy.com"
|
|
},
|
|
"_npmVersion": "5.4.2",
|
|
"_phantomChildren": {},
|
|
"_requested": {
|
|
"raw": "@expo/schemer@1.1.0",
|
|
"scope": "@expo",
|
|
"escapedName": "@expo%2fschemer",
|
|
"name": "@expo/schemer",
|
|
"rawSpec": "1.1.0",
|
|
"spec": "1.1.0",
|
|
"type": "version"
|
|
},
|
|
"_requiredBy": [
|
|
"/xdl"
|
|
],
|
|
"_resolved": "https://registry.npmjs.org/@expo/schemer/-/schemer-1.1.0.tgz",
|
|
"_shasum": "74e519233f82c8871d018475895043e4caef3e7e",
|
|
"_shrinkwrap": null,
|
|
"_spec": "@expo/schemer@1.1.0",
|
|
"_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/xdl",
|
|
"author": {
|
|
"name": "Wilson Zhao wilson.in@expo.io"
|
|
},
|
|
"dependencies": {
|
|
"ajv": "^5.2.2",
|
|
"babel-polyfill": "^6.23.0",
|
|
"babel-preset-flow": "^6.23.0",
|
|
"es6-error": "^4.0.2",
|
|
"file-type": "^5.2.0",
|
|
"instapromise": "^2.0.7",
|
|
"lodash": "^4.17.4",
|
|
"probe-image-size": "^3.1.0",
|
|
"read-chunk": "^2.0.0"
|
|
},
|
|
"description": "Centralized scheme validation library for Expo",
|
|
"devDependencies": {
|
|
"babel-cli": "^6.24.1",
|
|
"babel-jest": "^20.0.3",
|
|
"babel-preset-env": "^1.6.0",
|
|
"flow-bin": "^0.51.1",
|
|
"jest": "^20.0.4"
|
|
},
|
|
"directories": {},
|
|
"dist": {
|
|
"integrity": "sha512-3A9weL/nBXZ8sqPV8lP9g7qswmpzbGFRwvnIR8mF/CBZMwCx/JJ11QBS6mZwr7jm4kbU/C6D+HnDh3RjCHSSow==",
|
|
"shasum": "74e519233f82c8871d018475895043e4caef3e7e",
|
|
"tarball": "https://registry.npmjs.org/@expo/schemer/-/schemer-1.1.0.tgz"
|
|
},
|
|
"files": [
|
|
"build"
|
|
],
|
|
"license": "MIT",
|
|
"main": "./build/index.js",
|
|
"maintainers": [
|
|
{
|
|
"name": "davepack",
|
|
"email": "dave@expo.io"
|
|
},
|
|
{
|
|
"name": "abi",
|
|
"email": "abimanyuraja@gmail.com"
|
|
},
|
|
{
|
|
"name": "jesseruder",
|
|
"email": "jesse@sixfivezero.net"
|
|
},
|
|
{
|
|
"name": "terribleben",
|
|
"email": "ben@exp.host"
|
|
},
|
|
{
|
|
"name": "ccheever",
|
|
"email": "ccheever@gmail.com"
|
|
},
|
|
{
|
|
"name": "dikaiosune",
|
|
"email": "adam.n.perry@gmail.com"
|
|
},
|
|
{
|
|
"name": "nikki93",
|
|
"email": "s.nikhilesh@gmail.com"
|
|
},
|
|
{
|
|
"name": "brentvatne",
|
|
"email": "brentvatne@gmail.com"
|
|
},
|
|
{
|
|
"name": "skevy",
|
|
"email": "adam@sk3vy.com"
|
|
},
|
|
{
|
|
"name": "ide",
|
|
"email": "ide+npm@jameside.com"
|
|
},
|
|
{
|
|
"name": "expoadmin",
|
|
"email": "exponent.team@gmail.com"
|
|
}
|
|
],
|
|
"name": "@expo/schemer",
|
|
"optionalDependencies": {},
|
|
"readme": "# Schemer\nA Schema validation library for Expo, to be used both \nDetails can be found here:\nhttps://paper.dropbox.com/doc/Expo-Schema-Validation-Library-mQU07rRejSnEe4Vf5dkcS\n\n## Usage\n### Usage with XDL\n```javascript\nimport {ProjectUtils, ExpSchema} from 'xdl';\nimport Schemer from '@expo/schemer';\nconst {exp} = await ProjectUtils.readConfigJsonAsync(projectRoot)\nconst schema = await getSchemaAsync(exp.sdkVersion)\nconst validator = new Schemer(schema)\nvalidator.validateName('Wilson Zhao')\nvalidator.validateAssets(exp)\n```\n### Schema-only validation\n```javascript\nconst validator = new Schemer(require('schema.json'));\ntry {\n await validator.validateSchemaAsync(require('data.json'))\n} catch (e) {\n console.error(e)\n}\n```\n\n### Validating a property\n```javascript\nconst validator = new Schemer(require('schema.json'));\nawait validator.validateName('Wilson Zhao')\n```\n\n## Description\nSchemer takes in a custom JSON Schema and uses it to validate various data.\n\nUnder the hood, it uses Ajv (https://github.com/epoberezkin/ajv) as the Javascript engine for basic schema validation.\nHowever, each subschema also contains a custom meta tag, which can be parsed for further \"manual\" validation. As of now, Schemer supports manual validation for assets:\n\n```javascript\n{\n meta: \n {\n asset,\n contentType, //mime type\n dimensions: {width, height},\n square,\n\n // For custom error messages and docs\n regexHuman,\n autogenerated \n } \n}\n```\n\n\nAll errors can be accessed in `this.errors`, which has a getter function that combines Ajv JSON Schema errors with custom meta/asset validation errors into a unified array of `ValidationErrors`.\nIf they exist, the errors are thrown at the end of each public-facing function.\n\nAll public-facing functions are async functions because asset validation has to be async (accessing the file-system or making a web request).\n\n\n\n## API\n\n#### new Schemer(Object JSON Schema, Object options) -> Object\n\n#### .validateSchemaAsync(Object data) -> Promise\n\nReturns a promise that resolve to `true` if the data is conforms to the schema. Otherwise, it rejects and throws an array of `ValidationError`s.\n\n#### .validateAssetsAsync(Object data) -> Promise\n\nReturns a promise that resolve to `true` if the data is conforms to the additional validation steps found in each meta tag. For example, it will download an asset and read the header of the file to see if it is a certain content type. \nOtherwise, it rejects and throws an array of `ValidationError`s.\n\n#### .validateAll(Object data) -> Promise\n\nRuns both `.validateSchemaAsync` and `.validateAssetsAsync`. \nReturns a promise that resolve to `true` if the data passes both functions. Otherwise, it rejects and throws an array of `ValidationError`s.\n\n#### .validateProperty(String fieldPath, Object data) -> Promise\n\nExtracts the subSchema for the given field path and validates the data against it. Also checks for the meta tag. \nReturns a promise that resolve to `true` if the data conforms to the subschema. Otherwise, it rejects and throws an array of `ValidationError`s.\n\n#### .errors\n\nContains an array of ValidationErrors\n\n#### new ValidationError({errorCode, fieldPath, message, data, meta}) -> Object\n\n\n\n\n\n",
|
|
"readmeFilename": "README.md",
|
|
"scripts": {
|
|
"build": "mkdir -p build; babel src -d build",
|
|
"buildbg": "babel -w src -d build &",
|
|
"prepare": "npm run build",
|
|
"test": "jest",
|
|
"testWatch": "npm run buildbg; jest --watch",
|
|
"watch": "babel -w src -d build"
|
|
},
|
|
"version": "1.1.0"
|
|
}
|