Members
# static constant createRowFields
Give an array of fields, create an array of rows with the fields give a column count
Object
# inner constant VALID_PATTERNS
regex patterns for validating fields
Properties:
Name | Type | Description |
---|---|---|
PHONE |
RegExp
|
regex pattern for validating phone numbers |
EMAIL |
RegExp
|
regex pattern for validating email addresses |
ZIP |
RegExp
|
regex pattern for validating zip codes |
Methods
# async static attemptFormSubmit(formData, isEdit, options) → {Promise.<void>}
Method to reduce the amount of boilerplate code needed to submit a form
Parameters:
Name | Type | Description |
---|---|---|
formData |
object
|
data to submit |
isEdit |
boolean
|
true if editing, false if creating |
options |
SubmitOptions
|
options object |
- promise that resolves when the submit is complete
Promise.<void>
# static createFieldValidation(type, label, validationMap, field) → {YupSchema}
Create a yup schema for a given field type
Parameters:
Name | Type | Description |
---|---|---|
type |
number
|
|
label |
string
|
|
validationMap |
Map
|
|
field |
object
|
- yup schema for a field
YupSchema
# static getSelectValue(multiple, inData) → {string}
Extract the id of the selected item from the data
Parameters:
Name | Type | Description |
---|---|---|
multiple |
boolean
|
is the field a multiselect |
inData |
object
|
data to be extracted and formatted |
- string of the id of the selected item or array of ids of selected items
string
# static multiToPayload(selectionsopt) → {Array.<{id: number}>}
Covert multiselect form input into an api ready array
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
selections |
Array.<object>
|
<optional> |
array of selected items |
- array of selected items with id
Array.<{id: number}>
# static useFormSubmit() → {FormSubmitOptions}
Helper to create hook bits for form submit
FormSubmitOptions
Example
const { modifying, setModifying, nav, enqueueSnackbar } = useFormSubmit();
# static validCurrencyFormat(value) → {boolean}
Return whether or not the value is a valid currency format
Parameters:
Name | Type | Description |
---|---|---|
value |
string
|
- true if the value is a valid currency format
boolean
# static validDateFormat(value) → {boolean}
Test the value to see if it is a valid date
Parameters:
Name | Type | Description |
---|---|---|
value |
string
|
- true if the value is a valid date
boolean
# static validDoubleFormat(value, i, f) → {boolean}
Format validation for a double value
if i and f are not passed in, the default is 4 digits before and 4 digits after the decimal
if i or f are passed in and are not numbers, the default is 999999999 digits before and after the decimal
Parameters:
Name | Type | Description |
---|---|---|
value |
number
|
|
i |
number
|
number of digits before decimal |
f |
number
|
number of digits after decimal |
- true if the value is a valid double format
boolean
# static yupCurrency(label, isRequiredopt, maxLengthopt, msgopt, reqMessageopt, minLengthopt) → {YupSchema}
Create a yup schema for a currency field that checks max/min length
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
label |
string
|
label for the field | |
isRequired |
boolean
|
<optional> |
is the field required |
maxLength |
number
|
<optional> |
max length of the field |
msg |
string
|
<optional> |
message to display if the field is not formatted correctly |
reqMessage |
string
|
<optional> |
message to display if the field is required |
minLength |
number
|
<optional> |
min length of the field |
- yup schema for a currency field
YupSchema
# static yupDate(label, isRequiredopt, msgopt, reqMessageopt) → {YupSchema}
Create a yup schema for a date field
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
label |
string
|
label for the field | |
isRequired |
boolean
|
<optional> |
is the field required |
msg |
string
|
<optional> |
message to display if the field is not a valid date |
reqMessage |
string
|
<optional> |
message to display if the field is required |
- yup schema for a date field
YupSchema
# static yupFloat(label, isRequiredopt, intopt, fracopt, maxLengthopt, msgopt, maxValueopt, reqMessageopt, minLengthopt, minValueopt) → {YupSchema}
Create a yup schema for a float field that checks max/min length
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
label |
string
|
label for the field | |
isRequired |
boolean
|
<optional> |
is the field required |
int |
number
|
<optional> |
max number of integers |
frac |
number
|
<optional> |
max number of decimals |
maxLength |
number
|
<optional> |
max length of the field |
msg |
string
|
<optional> |
message to display if the field is not in the correct format |
maxValue |
string
|
<optional> |
max value of the field |
reqMessage |
string
|
<optional> |
message to display if the field is required |
minLength |
number
|
<optional> |
min length of the field |
minValue |
number
|
<optional> |
min value of the field |
YupSchema
# static yupInt(label, isRequiredopt, maxLengthopt, msgopt, reqMessageopt, minLengthopt) → {YupSchema}
Create a yup schema for an integer field that checks max/min length
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
label |
string
|
label for the field | |
isRequired |
boolean
|
<optional> |
is the field required |
maxLength |
number
|
<optional> |
max length of the field |
msg |
string
|
<optional> |
message to display if the field is not an integer |
reqMessage |
string
|
<optional> |
message to display if the field is required |
minLength |
number
|
<optional> |
min length of the field |
YupSchema
# static yupMultiselect(label, isRequired, reqMessage) → {YupSchema}
Create a yup schema for a multiselect field
Parameters:
Name | Type | Description |
---|---|---|
label |
string
|
label for the field |
isRequired |
boolean
|
is the field required |
reqMessage |
string
|
message to display if the field is required |
- yup schema for a string field
YupSchema
# static yupObject(label, isRequired, reqMessage) → {YupSchema}
Create a yup schema for a generic or custom object field
Parameters:
Name | Type | Description |
---|---|---|
label |
string
|
label for the field |
isRequired |
boolean
|
is the field required |
reqMessage |
string
|
message to display if the field is required |
- yup schema for an object field
YupSchema
# static yupString(label, isRequiredopt, reqMessageopt) → {YupSchema}
Create a yup schema for a string field
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
label |
string
|
||
isRequired |
boolean
|
<optional> |
|
reqMessage |
string
|
<optional> |
- yup schema for the field
YupSchema
# static yupTrimString(label, isRequiredopt, trimMsgopt, reqMessageopt) → {YupSchema}
Create a yup schema for a string field that ensures the value is trimmed
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
label |
string
|
label for the field | |
isRequired |
boolean
|
<optional> |
is the field required |
trimMsg |
string
|
<optional> |
message to display if the field is not trimmed |
reqMessage |
string
|
<optional> |
message to display if the field is required |
- yup schema for the field
YupSchema
# static yupTrimStringMax(label, isRequired, maxLength, msg, reqMessage, minLength) → {YupSchema}
Trim a string and check max/min and remove any leading or trailing spaces
Parameters:
Name | Type | Description |
---|---|---|
label |
string
|
label for the field |
isRequired |
boolean
|
is the field required |
maxLength |
number
|
max length of the field |
msg |
string
|
message to display if the field is not formatted correctly |
reqMessage |
string
|
message to display if the field is required |
minLength |
number
|
min length of the field |
- yup schema for a string field
YupSchema
# static yupTypeAhead(label, isRequiredopt, reqMessageopt) → {YupSchema}
Create a yup schema for a typeahead field
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
label |
string
|
label for the field | |
isRequired |
boolean
|
<optional> |
is the field required |
reqMessage |
string
|
<optional> |
message to display if the field is required |
- yup schema for the field
YupSchema
# inner addMaxLength(schema, label, maxLength) → {YupSchema}
Add a max length test to a yup schema
Parameters:
Name | Type | Description |
---|---|---|
schema |
YupSchema
|
|
label |
string
|
|
maxLength |
number
|
- yup schema with a max length test
YupSchema
# inner addMaxValue(schema, label, maxValue, isIntopt) → {YupSchema}
Add a test to a yup schema to check the max value of a field
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
schema |
YupSchema
|
the schema to add the test to | |
label |
string
|
label for the field | |
maxValue |
string
|
number
|
the max value the field can be | |
isInt |
boolean
|
<optional> |
should the test be for an integer or a float |
YupSchema
# inner addMinLength(schema, label, minLength) → {YupSchema}
Add a min length test to a yup schema
Parameters:
Name | Type | Description |
---|---|---|
schema |
YupSchema
|
|
label |
string
|
|
minLength |
number
|
- yup schema with a min length test
YupSchema
# inner addMinValue(schema, label, minValue, isIntopt) → {YupSchema}
Add a test to a yup schema to check the min value of a field
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
schema |
YupSchema
|
the schema to add the test to | |
label |
string
|
label for the field | |
minValue |
string
|
number
|
the max value the field can be | |
isInt |
boolean
|
<optional> |
should the test be for an integer or a float |
YupSchema