Fields
Field Validation

Field validation

FieldDescriptionValue
requiredMarks a field as mandatory.It accepts either a boolean value or an object with value and errorMsg as child props
patternAdds a pattern validation for the field. For email, pattern is supported by defaultIt accepts either a string value or an object with value and errorMsg as child props
minFor Textbox fields, it is the minimum number of characters required for the field,
For number fields, it is the minimum value allowed
It accepts either a string or number value or an object with value and errorMsg as child props
maxFor Textbox fields it is the maximum number of characters allowed.
For number fields, it is the maximum value allowed
It accepts either a string or number value or an object with value and errorMsg as child props
infoThis is for providing hints or more info about the field. Type is stringIt accepts a string value
patternDetail (deprecated)Contains info msg and error msg for pattern validation property
minDetail (deprecated)Contains error and info msg for min validation property
maxDetail (deprecated)Contains error and info msg for max validation property
infoDetail (deprecated)Contains general info msg about the field
requiredDetail (deprecated)Contains info msgs about the required validation property

Note: Deprecated properties will not be supported in future releases.

Validation schema format

Requried validation

{
    "validation": {
        "required": true
    }
}

Requried validation with custom error message

{
    "validation": {
        "required": {
            "value": true,
            "errorMsg": "This is a custom error message"
        }
    }
}

Pattern validation

{
    "validation": {
        "pattern": "^[A-Za-z]{1,32}$"
    }
}

Pattern validation with custom error message

{
    "validation": {
        "pattern": {
            "value": "^[A-Za-z]{1,32}$",
            "errorMsg": "The data pattern is not correct"
        }
    }
}

Minimum and maximum characters validation

{
    "validation": {
        "min": {
            "value": "3",
            "errorMsg": "Password should be of minimum 3 length"
        },
        "max": {
            "value": "20",
            "errorMsg": "Password max length should be 20"
        }
    }
}

Basic example

Schema details

{
fields
:
[
[
…
]
[
…
]
]
}

Star us at github

© Copyright 2023 MuiForms