1.3.1 • Published 5 years ago

js-laravel-validation v1.3.1

Weekly downloads
103
License
ISC
Repository
github
Last release
5 years ago

js-laravel-validation npm version Build Status

Useful for having consistent server side and client side validation with Laravel

All rules are base on documentation from https://laravel.com/docs/5.7/validation#available-validation-rules

Setup

Install: npm install js-laravel-validation

Usage

  import { validateForm } from "js-laravel-validation";

  const formData = {
    username: {
      value: "test1",
      validation: "required|string"
    },
    password: {
      value: null,
      validation: "required|string"
    }
  };

  const result = validateForm({ formData });

  if (result.errors) {
    console.log(result.errors); // will be { password: ['required', 'string'] }
  }

Docs

Function NameDescription
validateForm(options)Takes a number of options to validate the form data
setMessageHandler(rule, createMessage)Sets or replaces the current message handler for the specified rule
setMessageHandlers(messages)Replaces multiple message handers

Missing Rules

  • active_url
    • This cannot be supported because JS does not support hostname lookups (dns_get_record in PHP)
    • This could be implemented if there was a reliable way to host a small API to do the lookup
  • date_format
    • This can be added with something like return new Date(value).format(params[0]) === value;
    • Unfortunately that isn't so easy in vanilla js atm
  • exists & unqiue

    • These are both rules relating to the database
  • not_regex (to come)

  • regex (to come)

    • Regex requires extra parsing to remove forward slashes around regex
1.3.1

5 years ago

1.3.0

5 years ago

1.2.10

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago