noahsalvi / svelte-use-form

The most compact reactive form controller (including Validation) that you'll ever see.
MIT License
252 stars 14 forks source link

Add pattern validator to validators #33

Closed salvatoreromeo closed 2 years ago

salvatoreromeo commented 2 years ago

I created this validator as a generica pattern validator.

Usage is as follows (example of a pattern regexp having at least 8 chars/numbers and a special char):

<input type="password" name="password" use:validators={[ required, pattern(/^(?=.?[A-Z])(?=.?[a-z])(?=.?[0-9])(?=.?[#?!@$%^&*-]).{8,}$/) ]} />

noahsalvi commented 2 years ago

I created this validator as a generica pattern validator.

Usage is as follows (example of a pattern regexp having at least 8 chars/numbers and a special char):

<input type="password" name="password" use:validators={[ required, pattern(/^(?=.?[A-Z])(?=.?[a-z])(?=.?[0-9])(?=.?[#?!@$%^&*-]).{8,}$/) ]} />

Awesome, good idea! Expected to be in the next release.

salvatoreromeo commented 2 years ago

very good @noahsalvi