Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@winexy/fuji

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@winexy/fuji

Composable schema validation utility library

  • 0.1.0-beta.21
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

version types minified minified + gzip dependencies tree-shaking

🗻 fuji

🎼  Composable schema validation utility library

Example

import { f, run, string, int, required, oneOf, pattern } from '@winexy/fuji'
import type { Infer } from '@winexy/fuji'

const urlRegex = /.../

const schema = f.shape({
  name: f(string(), required()),
  version: f(pattern(/\d+\.\d+.\d+/)),
  workspaces: f.array(f(string())),
  repository: f.shape({
    type: f(string(), required(), oneOf(['git', 'vcs'])),
    url: f(string(), pattern(urlRegex))
  })
})

type PackageType = Infer<typeof schema>
/*
{
  name: string,
  version?: string,
  workspaces?: string[],
  repository?: {
    type: string,
    url?: string
  }
}
*/


const result = run(schema, {
  name: '@winexy/fuji',
  version: '0.0.0',
  repository: {
    type: 'git',
    url: 'https://github.com/winexy/fuji'
  }
})

if (result.invalid) {
  result.errors // Array<VError>
  result.value // null
} else {
  result.errors // null
  result.value // same as PackageType
}

Troubleshooting

Infer<typeof schema> infers any

Set strictFunctionTypes mode to true in your tsconfig.json compilerOptions section

{
  "compilerOptions": {
    "strictFunctionTypes": true
  } 
}

Keywords

FAQs

Package last updated on 10 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc