Class validatorOptions not found

Class validatorOptions not found

dataBdataB Posts: 23Questions: 5Answers: 1

In Editor v1.8.1 (php v7.2) I'm getting the following error when trying to call ValidateOptions: "Uncaught Error: Class 'ValidateOptions' not found in..."

Here's the code:

Field::inst( 'candidates.email' )
  ->validator( Validate::email(
   ValidateOptions::inst()
   ->allowEmpty( false )
   ->optional( false )
 ) ),

However, Validate works as expected. For example:

Field::inst( 'candidates.email' )
  ->validator( Validate::email() ),

I can see the ValidateOptions.php file in the Editor folder and the code looks ok. Any ideas?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Have you got DataTables\Editor\ValidateOptions; in your use statement? e.g.:

    use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Mjoin,
        DataTables\Editor\Options,
        DataTables\Editor\Upload,
        DataTables\Editor\Validate,
        DataTables\Editor\ValidateOptions;
    

    Without that you would need to specify the full namespace:

       DataTables\Editor\ValidateOptions::inst()
         ->allowEmpty( false )
         ->optional( false )
    

    Allan

This discussion has been closed.