Skip to content

Validator not populating flashSession #4823

@sn0rcha

Description

@sn0rcha

Package version

@adonisjs/core@6.15.2, @adonisjs/inertia@1.2.4

Describe the bug

I'm having a bizarre issue with request.validateAll where if an element in the object exceeds a certain string length, the validator doesn't populate the flashSession with the errors:

My validation:

export const assignmentValidator = vine.compile(
  vine.object({
    name: vine.string().trim(),
    student_id: vine.number(),
    category: vine.string().trim(),
    status: vine.string().trim(),
    learning_level: vine.number(),
    due_date: vine.string().trim(),
    source_content: vine.string().trim().nullable().optional(),
    source_file: vine.string().trim().nullable().optional(),
    instructions: vine.string().trim(),
    instructions_notes: vine.string().trim().nullable(),
    score_pass: vine.number(),
  })
)

If I send source_content with a string length longer than 2403, it never populates the flashSession with any errors, anything less is fine.

Any ideas? - My bodyParser config is set to 60 MB on all types.

PLEASE NOTE: If I wrap the request.validateUsing() in a try / catch I get the following when clearing the name field and submitting - so the validation is working - it's just not populating the flashSession for some reason:

{
  status: 422,
  code: 'E_VALIDATION_ERROR',
  messages: [
    {
      message: 'The name field must be defined',
      rule: 'required',
      field: 'name'
    }
  ]
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions