0.0.53 • Published 4 years ago

silk-way-validate v0.0.53

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

silk-way-validate

###install npm install silk-way-validate

###How to use

import Validation from 'silk-way-validate'
Validation.validate("notNull", "some text", "error message")
//{ isValid: true, errorText: "error message" }

###validators

ValidatorsDescriptionType
notNullcheck for empty stringstring
phonecheck for valid phone number (KZ)string
iincheck for valid IIN (KZ)string
booleanTruecheck for TRUEboolean
cyrilliccheck for cyrillic textstring

##example

import Validation from 'silk-way-validate'
let userData = [
    { id: "name", value: "Валодя", validation: "cyrillic" },
    { id: "phone", value: "+7 (777) 123 - 11 - 00", validation: "phone" },
    { id: "iin", value: "111111000222", validation: "iin" }
]
userData.map(item => {
    item.valid = Validation.validate(item.validation, item.value)
})

[
  {
    id: 'name',
    value: 'Валодя',
    validation: 'cyrillic',
    valid: { isValid: true, errorText: 'messageErrorNull' }
  },
  {
    id: 'phone',
    value: '+7 (777) 123 - 11 - 00',
    validation: 'phone',
    valid: { isValid: true, errorText: 'messageNotNullPhone' }
  },
  {
    id: 'iin',
    value: '111111000222',
    validation: 'iin',
    valid: { isValid: false, errorText: 'messageErrorIin' }
  }
]

###example with require('silk-way-validate')

const Validation = require("silk-way-validate")
let userData = [
    { id: "name", value: "Валодя", validation: "cyrillic" },
    { id: "phone", value: "+7 (777) 123 - 11 - 00", validation: "phone" },
    { id: "iin", value: "111111000222", validation: "iin" }
]
userData.map(item => {
    item.valid = Validation.default.validate(item.validation, item.value)
})

[
  {
    id: 'name',
    value: 'Валодя',
    validation: 'cyrillic',
    valid: { isValid: true, errorText: 'messageErrorNull' }
  },
  {
    id: 'phone',
    value: '+7 (777) 123 - 11 - 00',
    validation: 'phone',
    valid: { isValid: true, errorText: 'messageNotNullPhone' }
  },
  {
    id: 'iin',
    value: '111111000222',
    validation: 'iin',
    valid: { isValid: false, errorText: 'messageErrorIin' }
  }
]

##future plans

validate email, latin string and more

0.0.53

4 years ago

0.0.52

4 years ago

0.0.51

4 years ago

0.0.50

4 years ago

0.0.49

4 years ago

0.0.48

4 years ago

0.0.47

4 years ago

0.0.45

4 years ago

0.0.44

4 years ago

0.0.41

4 years ago

0.0.42

4 years ago

0.0.43

4 years ago

0.0.4

4 years ago

0.0.32

4 years ago

0.0.31

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago