0

Can someone tell me what i am doing wrong here?

// Some other validation rules
[['FILE_BLOB'], 'file' , 'maxSize' => 1024 * 1024, 'message' => 'Here goes my message'],
//Some more validation rules

Well my problem is that validator works fine, but it shows it's inbuilt errorMessage in case i want to upload bigger files. Not the one that i specified in 'message' => 'Here goes my message'

And how can i get my own errorMessage in case there are 2 validators?!

[['FILE_BLOB'], 'file' , 'extensions' => ['pdf','text'], 'maxSize' => 1024 * 1024],

I guess the easy way would be to split validations like this:

[['FILE_BLOB'], 'file' , 'maxSize' => 1024 * 1024],
[['FILE_BLOB'], 'file' , 'extensions' => ['pdf','text']],

But 1st i need to get to work these messages.

EDIT:

Problem solved. Need to be more careful with reading documentation. For custom message with file size need to use 'tooBig' or 'tooSmall', but for extension custom message need to use 'wrongExtension'.

arccuks
  • 173
  • 2
  • 12
  • 1
    why peolpe do not read the documentations before asking questions :| – iamawebgeek Jul 27 '15 at 10:36
  • i read, but as i already stated, i was too much focused on property - `'message'`. I didn't even considered that there can be another thing that i need to look for. – arccuks Jul 27 '15 at 12:49

1 Answers1

4

Try tooBig and tooSmall property:

[['FILE_BLOB'], 'file' , 'maxSize' => 1024 * 1024, 'tooBig' => 'message when file size is large'],

For more details refer link

Chinmay Waghmare
  • 5,368
  • 2
  • 43
  • 68