Comparing version 6.5.1 to 6.6.0
@@ -59,3 +59,4 @@ "use strict"; | ||
CONTENT_INCORRECT: function (self, details) { | ||
var message = "Expected ".concat((0, show_1.default)(self), ", but was incompatible"); | ||
var formattedDetails = JSON.stringify(details, null, 2).replace(/^ *null,\n/gm, ''); | ||
var message = "Validation failed:\n".concat(formattedDetails, ".\nObject should match ").concat((0, show_1.default)(self)); | ||
return (0, exports.FAILURE)(result_1.Failcode.CONTENT_INCORRECT, message, details); | ||
@@ -62,0 +63,0 @@ }, |
{ | ||
"name": "runtypes", | ||
"version": "6.5.1", | ||
"version": "6.6.0", | ||
"description": "Runtime validation for static types", | ||
@@ -27,2 +27,3 @@ "main": "./lib/index.js", | ||
"jest-github-actions-reporter": "^1.0.3", | ||
"outdent": "^0.8.0", | ||
"prettier": "^2.2.1", | ||
@@ -54,3 +55,4 @@ "ts-jest": "^26.5.4", | ||
}, | ||
"dependencies": {} | ||
"dependencies": {}, | ||
"packageManager": "yarn@1.22.19" | ||
} |
@@ -115,2 +115,13 @@ # Runtypes [![Build Status](https://travis-ci.org/pelotom/runtypes.svg?branch=master)](https://travis-ci.org/pelotom/runtypes) [![Coverage Status](https://coveralls.io/repos/github/pelotom/runtypes/badge.svg?branch=master)](https://coveralls.io/github/pelotom/runtypes?branch=master) | ||
## Error information | ||
When it fails to validate, your runtype emits a `ValidationError` object that contains detailed information that describes what's the problem. Following properties are available in the object: | ||
- `name`: Always `"ValidationError"` | ||
- `message`: A `string` that summarizes the problem overall | ||
- `code`: A [`Failcode`](https://github.com/pelotom/runtypes/blob/dcd4fe0d0bd0fc9c3ec445bda30586f3e6acc71c/src/result.ts#L12-L33) that categorizes the problem | ||
- `details`: An object that describes which property was invalid precisely; only for complex runtypes (e.g. `Record`, `Array`, and the like) | ||
If you want to inform your users about the validation error, it's strongly discouraged to rely on the format of `message` property in your code, as it may change across minor versions for readability thoughts. Instead of parsing `message`, you should use `code` and/or `details` property to programmatically inspect the validation error, and handle other stuff such as i18n. | ||
## Static type inference | ||
@@ -117,0 +128,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123936
2529
552
8