summaryrefslogtreecommitdiff
path: root/app/utils/validate.ts
diff options
context:
space:
mode:
Diffstat (limited to 'app/utils/validate.ts')
-rw-r--r--app/utils/validate.ts16
1 files changed, 12 insertions, 4 deletions
diff --git a/app/utils/validate.ts b/app/utils/validate.ts
index 91db9b6..862b2d0 100644
--- a/app/utils/validate.ts
+++ b/app/utils/validate.ts
@@ -1,4 +1,4 @@
-const ValidateJS = require("validate.js")
+const ValidateJS = require('validate.js')
// HACK(steve): wierd typescript situation because of strange typings
const Validate: any = ValidateJS.default ? ValidateJS.default : ValidateJS
@@ -6,7 +6,12 @@ const Validate: any = ValidateJS.default ? ValidateJS.default : ValidateJS
/**
* Validates that 1 attribute doesn't appear in another's attributes content.
*/
-Validate.validators.excludes = function custom(value, options, key, attributes) {
+Validate.validators.excludes = function custom(
+ value,
+ options,
+ key,
+ attributes,
+) {
const list = attributes[options.attribute] || []
if (value && list.includes(value)) {
return options.message || `${value} is in the list`
@@ -69,8 +74,11 @@ export interface ValidationErrors {
* @param rules The rules to apply.
* @param data The object to validate.
*/
-export function validate(rules: ValidationRules, data: Record<string, unknown>): ValidationErrors {
- if (typeof data !== "object") {
+export function validate(
+ rules: ValidationRules,
+ data: Record<string, unknown>,
+): ValidationErrors {
+ if (typeof data !== 'object') {
return {} as ValidationErrors
}
return Validate(data, rules, { fullMessages: false }) || {}