Socket
Socket
Sign inDemoInstall

validation.ts

Package Overview
Dependencies
2
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.0.5

2

lib/validation.d.ts

@@ -7,2 +7,4 @@ import { Result, Ok, Err } from 'space-lift/result';

filter(fn: (value: T) => boolean): Validator<T>;
tagged<TAG extends string>(this: Validator<string>): Validator<TAG>;
tagged<TAG extends number>(this: Validator<number>): Validator<TAG>;
}

@@ -9,0 +11,0 @@ export declare type Any = Validator<Object>;

@@ -34,2 +34,5 @@ "use strict";

};
Validator.prototype.tagged = function () {
return this;
};
return Validator;

@@ -36,0 +39,0 @@ }());

2

package.json
{
"name": "validation.ts",
"version": "0.0.4",
"version": "0.0.5",
"description": "Validation for TypeScript",

@@ -5,0 +5,0 @@ "main": "lib/validation.js",

@@ -51,2 +51,14 @@ # validation.ts

### tagged primitive
Sometimes, a `string` or a `number` is not just any string or number but carry extra meaning, e.g: `email`, `uuid`, `userId`, `KiloGram`, etc.
Tagging such a primitive as it's validated can help make the downstream code more robust.
```ts
type UserId = string & { __tag: 'UserId' } // Note: You can use any naming convention for the tag.
const userIdValidator = v.string.tagged<UserId>()
```
## literal

@@ -53,0 +65,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc