build improvements
This commit is contained in:
23
yoga-app/src/validation/validation.ts
Normal file
23
yoga-app/src/validation/validation.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import Ajv, {JSONSchemaType} from "ajv"
|
||||
import addFormats from "ajv-formats"
|
||||
import {ContactFormData} from "@/actions/contactus-actions";
|
||||
|
||||
const ajv = new Ajv({allErrors: true}) // options can be passed, e.g. {allErrors: true}
|
||||
addFormats(ajv)
|
||||
|
||||
const contactUsFormSchema: JSONSchemaType<ContactFormData> = {
|
||||
type: "object",
|
||||
properties: {
|
||||
firstname: {type: "string",minLength: 3,maxLength: 20},
|
||||
lastname: {type: "string",minLength: 3,maxLength: 20},
|
||||
phone: {type: "string",minLength: 3,maxLength: 20},
|
||||
email: {type: "string", format: 'email'},
|
||||
comment: {type: "string",minLength: 3,maxLength: 500}
|
||||
},
|
||||
required: ["firstname","lastname","phone","email","comment"],
|
||||
additionalProperties: true
|
||||
}
|
||||
|
||||
export const contactUsFormValidator = ajv.compile(contactUsFormSchema)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user