DONE
This commit is contained in:
24
repositories/schema.js
Normal file
24
repositories/schema.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { object, boolean, date, number, string } from 'yup'
|
||||
|
||||
export const webFields = { title: null, category: null, archive: null, content: null }
|
||||
export const idOnlySchema = number().integer().positive().min(1).max(1024).required()
|
||||
|
||||
const initialSchema = {
|
||||
updated_at: string().nullable().default(null),
|
||||
created_at: date().default(() => new Date()),
|
||||
content: string().ensure().max(1024),
|
||||
archive: boolean().nullable().default(false),
|
||||
category: string().matches(/^(random_thought|idea|task|quote)$/).required(),
|
||||
title: string().trim().min(1).max(127).required(),
|
||||
id: string().nullable().default(null),
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine exportable schemas using previously created chunks along with adding a new ones dynamically
|
||||
*/
|
||||
|
||||
export const newNoteSchema = object(initialSchema)
|
||||
|
||||
initialSchema.id = idOnlySchema
|
||||
initialSchema.updated_at = date().default(() => new Date())
|
||||
export const updateNoteSchema = object(initialSchema)
|
||||
Reference in New Issue
Block a user