0.1.1 • Published 4 months ago

hannah-password-rules v0.1.1

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

Hannah Password Rules

A list of functions that can be selected into the Admin Dashboard to match the rules in Frontend and Backend.

Installation

npm install hannah-password-rules

Usage with Vue 3

    import { passwordRules } from 'hannah-password-rules'

    const activeValidations = {
      // Maximum length of password
      max_length: {
        required: true,
        value: 1
      }
      // Minimum length of password
      min_length: {
        required: true,
        value: 1
      }
      // How many mayus characters are required or none if required value is false
      mayus_quantity: {
        required: true,
        value: 1
      }
      // How many minus characters are required or none if required value is false
      minus_quantity: {
        required: true,
        value: 1
      }
      // How many numbers are required or none if required value is false
      number_quantity: {
        required: true,
        value: 1
      }
      // How many special characters are required or none if required value is false
      special_char_quantity: {
        required: true,
        value: 1
      }
      // If exists words that are not allowed to use in password
      with_disallowed_words: {
        required: true,
        value: 1
      }
      // If user's name is not allowed to use in password
      with_disallowed_user_name: {
        required: true,
        value: 1
      }
      // If user's email is not allowed to use in password
      with_disallowed_user_email: {
        required: true,
        value: 1
      }
      // If user's phone is not allowed to use in password
      with_disallowed_user_phone: {
        required: true,
        value: 1
      }
    }
    const words = ref(['word_1','word_3','word_2'])
    const props = ref({
      name: 'User`s name',
      email: 'example@mail.com',
      phone: '5512345678'
    })

    const validations = ref(passwordRules(
      activeValidations.value,
      words.value,
      props.value
    ))

    /**
    * @returns Object with same keys of activeValidations but with true or false value
    * Additional key valid is present with a global result of all tests
    */
    const results = validatations.value.test()
0.1.1

4 months ago

0.1.0

4 months ago