Validation

Solid Formly give you a core rules or customize your own for validation a form 💯.

Core rules
const fields = [{ ..., rules: [ 'required', 'min:number', 'max:number', 'between:number:number', 'equal:number', 'email', 'url' 'file' ] }];
Custom rules
import { IField, getValues } from "solid-formly"; async function notEqual(): boolean { const values = await getValues(form_name); if (values.firstname === values.lastname) { return false; } return true; } async function customRule2(): boolean { const values = await getValues(form_name); .... } const fields: IField[] = [ { type: "input", name: "firstname", attributes: { id: "firstname" }, }, { type: "input", name: "lastname", attributes: { id: "lastname" }, rules: [notEqual, customRule2], messages: { // Custom message error // property name must equal to function name. notEqual: "Last name must not equal to First name", customRule2: "foo bar" } } ];
Field file rules

In case you need to use file rules, must to add a file attribute to object's field with list rules, ex:

const fields: IField[] = [{ type: "file", name: "name-file", attributes: { id: "id-field", classes: ["form-control"], label: "Image" }, extra: { showPreview: true, multiple: true }, rules: ["file"], file: { types: "jpg,gif,png", // extensions maxsize: 5 // 5MB } }];