Clean up create app modal error messages

This commit is contained in:
Andrew Kingston 2021-04-15 19:31:04 +01:00
parent 910ac855cf
commit 3bdb484159
1 changed files with 6 additions and 5 deletions

View File

@ -14,6 +14,7 @@
import analytics from "analytics" import analytics from "analytics"
import { onMount } from "svelte" import { onMount } from "svelte"
import Logo from "/assets/bb-logo.svg" import Logo from "/assets/bb-logo.svg"
import { capitalise } from "../../helpers"
export let template export let template
@ -24,18 +25,18 @@
const steps = [Info, User] const steps = [Info, User]
let validators = [ let validators = [
{ {
applicationName: string().required("Your application must have a name."), applicationName: string().required("Your application must have a name"),
}, },
{ {
email: string() email: string()
.email() .email()
.required("Your application needs a first user."), .required("Your application needs a first user"),
password: string().required( password: string().required(
"Please enter a password for your first user." "Please enter a password for your first user"
), ),
roleId: string() roleId: string()
.nullable() .nullable()
.required("You need to select a role for your user."), .required("You need to select a role for your user"),
}, },
] ]
@ -68,7 +69,7 @@
await obj.validate(values, { abortEarly: false }) await obj.validate(values, { abortEarly: false })
} catch (validationErrors) { } catch (validationErrors) {
validationErrors.inner.forEach(error => { validationErrors.inner.forEach(error => {
$errors[error.path] = error.message $errors[error.path] = capitalise(error.message)
}) })
} }
valid = await obj.isValid(values) valid = await obj.isValid(values)