JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 33
  • Score
    100M100P100Q24626F
  • License Apache-2.0

A set of validators that are designed for Vuetify and Lancet in Decorator form.

Package Exports

  • @lancercomet/yunomix
  • @lancercomet/yunomix/dist/index.esm.js
  • @lancercomet/yunomix/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@lancercomet/yunomix) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Yunomix

MyWebLibs npm version

This is a set of validators that are designed for Vuetify and Lancet in @Decorator form.

Quick start

// Please make sure "reflect-metadata" is imported at your project entry.
import 'reflect-metadata'
import {
  Required, MinLength, MaxLength,
  IsEnglish, IsNumber, IsHexColor,
  getValidatorRules
} from '@lancercomet/yunomix'

class User {
  @Required()
  @MaxLength(10, 'Name cannot be longer than 10.')
  @IsEnglish('Name must be English.')
  name: string = ''

  @IsNumber('Age must be a number.')
  age: number = 0

  @MinLength(5)
  addr: string = ''

  @IsHexColor()
  color: string = '#4fc315'
}

const rules = getValidatorRules(User)
const userInput = new User()

In Vuetify:

<v-textfield v-model="userInput.name" :rules="rules.name" />
<v-textfield v-model.number="userInput.age" :rules="rules.age" />
<v-textfield v-model="userInput.addr" :rules="rules.age" />
<v-textfield v-model="userInput.color" :rules="rules.color" />

In Lancet:

<lct-textfield v-model="userInput.name" :rules="rules.name" />
<lct-textfield v-model.number="userInput.age" :rules="rules.age" />
<lct-textfield v-model="userInput.addr" :rules="rules.age" />
<lct-textfield v-model="userInput.color" :rules="rules.color" />

Example

Please check the example folder.

Something you might to know

Yunomix depends on the very feature emitDecoratorMetadata which was introduced in TypeScript, so keep in mind:

  • You have to install and import reflect-metadata manually.
  • Not available in pure JavaScript enviroment. You have to use it with TypeScript.
  • Not available for ESBuild because ESBuild doesn't emit decorator metadata.

License

Apache-2.0