SFormValidateFeature
This package expose a simple SFormValidateFeature
class that allows you to validate
your forms before sending them to your backend.
Preview
Password
Loading code example. Please wait...
Nodes
Loading code example. Please wait...
Email field
Loading code example. Please wait...
Alphanumeric field
Loading code example. Please wait...
Credit card field
Loading code example. Please wait...
Min / Max
Loading code example. Please wait...
Select field
Loading code example. Please wait...
Select min / max
Loading code example. Please wait...
Custom error message
Loading code example. Please wait...
ISO date field
Loading code example. Please wait...
Range min / max
Loading code example. Please wait...
Format
Loading code example. Please wait...
Checkboxes min / max
Loading code example. Please wait...
Submit / Reset
Loading code example. Please wait...
Features
-
Support for input value formatting using the
__format
function from '@coffeekraken/sugar/string' package -
Validate your field and display an error message if needed
-
Prevent your form to be submited when an error occurs
-
Built-in validators like
email
,min
,max
,pattern
, etc... -
Support custom validators through the @coffeekraken/s-validator package
-
Custom inline error message support
-
And more...
Import
Install
Events
-
error
Dispatched when a validation error occurs
-
valid
Dispatched when a validation pass correctly
Interface
-
minString|Array|Object|Number
Validate string, array, object and number using the "min" rule
-
maxString|Array|Object|Number
Validate string, array, object and number using the "max" rule
-
emailString
Validate an email string
-
requiredBoolean
Make sure a value has been provided
-
isoDateString
Validate an iso date string
-
isoTimeString
Validate an iso time string
-
isoDateTimeString
Validate an iso date string
-
integernumber
Validate an integer
-
numbernumber
Validate an number
-
negativenumber
Validate an negative number
-
positivenumber
Validate an positive number
-
patternString
Validate a string using a regex pattern
-
alphanumString
Validate an alphanum string
-
creditCardString
Validate a credit card string
-
colorString
Validate a color string
-
hexString
Validate a hexadecimal string
-
passwordString
Validate a password string
-
minMessageString
The message to display when the validator "min" fails
-
maxMessageString
The message to display when the validator "max" fails
-
emailMessageString
The message to display when the validator "email" fails
-
requiredMessageString
The message to display when the validator "required" fails
-
isoDateMessageString
The message to display when the validator "isoDate" fails
-
isoTimeMessageString
The message to display when the validator "isoTime" fails
-
isoDateTimeMessageString
The message to display when the validator "isoDateTime" fails
-
integerMessageString
The message to display when the validator "integer" fails
-
numberMessageString
The message to display when the validator "number" fails
-
negativeMessageString
The message to display when the validator "negative" fails
-
positiveMessageString
The message to display when the validator "positive" fails
-
patternMessageString
The message to display when the validator "pattern" fails
-
alphanumMessageString
The message to display when the validator "alphanum" fails
-
creditCardMessageString
The message to display when the validator "creditCard" fails
-
colorMessageString
The message to display when the validator "color" fails
-
hexMessageString
The message to display when the validator "hex" fails
-
passwordMessageString
The message to display when the validator "password" fails
-
typetextString
Specify the validation type. Usually automatically detected depending on the field type
-
on["keyup","change","submit","enter","reset"]
- keyup
- change
- submit
- enter
- reset
Array<String>Specify when to trigger a validation. Can be "change","submit","enter" and/or "reset"
-
format
- isoDate
- isoDateTime
- isoTime
- integer
- number
- alphanum
- hex
- hexa
- creditCard
StringSpecify if you want your value to be formatted a certain way. You can specify every "import { __format } from
@coffeekraken/sugar/string
" supported formats -
errorClasss-form-validate--error s-color--errorString
Specify the class to apply when theres an error
-
validClasss-form-validate--valid s-color--successString
Specify the class to apply on your s-form-validate element when validation is passed successfully
-
handlers{}Object
Specify some custom handlers by validator that will be executed in addition to the default validate behavior. The handler will take as argument an object containing the "result" SValidator result, the "$feature" that represent the s-validate node, the "$form" node if exists, the "$node" attached node if using the "nodes" property, the "$field" that represent the input field handled and the "props" that represent the feature properties
-
nodesString
Specify a css selector that target some HTMLElements used for the validation. Every HTMLElement has to specify 1 validator by using element attributes (same as on the feature itself). Classes are applied on each "node" to specify if the validator is valid or not
-
languageenString
Specify the language you want to use for messages
-
displayErrortrueBoolean
Specify if you want to display the error messages or not
-
errorContainerAttrs-form-validate-errorString
Specify the attribute to search for the error container. If not found, a default container will be created and inserted after your s-form-validate element