typescript-is
Advanced tools
Comparing version 0.6.5 to 0.6.6
@@ -57,5 +57,5 @@ /** | ||
/** | ||
* Options for the `AssertParameter` decorator. | ||
* Options for the `AssertType` decorator. | ||
*/ | ||
export interface AssertParameterOptions { | ||
export interface AssertTypeOptions { | ||
/** | ||
@@ -72,3 +72,3 @@ * Message that will be passed to the error constructor, in case type assertion fails. | ||
* @param options options for the decorator. | ||
* Check `AssertParameterOptions` documentation for more. | ||
* Check `AssertTypeOptions` documentation for more. | ||
* | ||
@@ -78,3 +78,3 @@ * @example | ||
@ValidateClass | ||
class A { method(@AssertParameter value: number) { value can safely be used a number } } | ||
class A { method(@AssertType value: number) { value can safely be used a number } } | ||
new A().method(0); // nothing happens | ||
@@ -84,3 +84,3 @@ new A().method('0' as any); // will throw an error | ||
*/ | ||
export function AssertParameter(options?: AssertParameterOptions): (target: object, propertyKey: string | symbol, parameterIndex: number) => void; | ||
export function AssertType(options?: AssertTypeOptions): (target: object, propertyKey: string | symbol, parameterIndex: number) => void; | ||
@@ -95,3 +95,3 @@ /** | ||
@ValidateClass | ||
class A { method(@AssertParameter value: number) { value can safely be used a number } } | ||
class A { method(@AssertType value: number) { value can safely be used a number } } | ||
new A().method(0); // nothing happens | ||
@@ -98,0 +98,0 @@ new A().method('0' as any); // will throw an error |
@@ -9,3 +9,3 @@ require('reflect-metadata'); | ||
function AssertParameter(assertion, options = {}) { | ||
function AssertType(assertion, options = {}) { | ||
return function (target, propertyKey, parameterIndex) { | ||
@@ -37,2 +37,2 @@ const assertions = Reflect.getOwnMetadata(assertionsMetadataKey, target, propertyKey) || []; | ||
module.exports = { is: warn, assertType: warn, createIs: warn, createAssertType: warn, AssertParameter, ValidateClass }; | ||
module.exports = { is: warn, assertType: warn, createIs: warn, createAssertType: warn, AssertType, ValidateClass }; |
{ | ||
"name": "typescript-is", | ||
"version": "0.6.5", | ||
"version": "0.6.6", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=6.14.4" |
@@ -145,3 +145,3 @@ # typescript-is | ||
## Decorators (`ValidateClass` and `AssertParameter`) | ||
## Decorators (`ValidateClass` and `AssertType`) | ||
@@ -168,7 +168,7 @@ You can also use the **decorators** to automate validation in class methods. | ||
```typescript | ||
import { ValidateClass, AssertParameter } from 'typescript-is'; | ||
import { ValidateClass, AssertType } from 'typescript-is'; | ||
@ValidateClass() | ||
class A { | ||
method(@AssertParameter() value: number) { | ||
method(@AssertType() value: number) { | ||
// You can safely use value as a number | ||
@@ -175,0 +175,0 @@ return value; |
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
71491