Module

formHelpers

Members

# static constant createRowFields

Give an array of fields, create an array of rows with the fields give a column count

View Source helpers/formHelpers.js, line 631

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

View Source helpers/formHelpers.js, line 13

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

View Source helpers/formHelpers.js, line 536

- 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

View Source helpers/formHelpers.js, line 387

- 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

View Source helpers/formHelpers.js, line 315

- 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

View Source helpers/formHelpers.js, line 72

- array of selected items with id
Array.<{id: number}>

# static useFormSubmit() → {FormSubmitOptions}

Helper to create hook bits for form submit

View Source helpers/formHelpers.js, line 617

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

View Source helpers/formHelpers.js, line 354

- 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

View Source helpers/formHelpers.js, line 63

- 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

View Source helpers/formHelpers.js, line 367

- 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

View Source helpers/formHelpers.js, line 226

- 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

View Source helpers/formHelpers.js, line 44

- 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

View Source helpers/formHelpers.js, line 138

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

View Source helpers/formHelpers.js, line 109

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

View Source helpers/formHelpers.js, line 303

- 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

View Source helpers/formHelpers.js, line 343

- 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>

View Source helpers/formHelpers.js, line 32

- 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

View Source helpers/formHelpers.js, line 95

- 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

View Source helpers/formHelpers.js, line 288

- 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

View Source helpers/formHelpers.js, line 83

- 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

View Source helpers/formHelpers.js, line 268

- 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

View Source helpers/formHelpers.js, line 165

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

View Source helpers/formHelpers.js, line 251

- 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

View Source helpers/formHelpers.js, line 195

YupSchema