public static function report_validation_errors(array $data, array &$errors) {
        // Empty value is allowed!
        if ($data['availabilityconditionsjson'] === '') {
            return;
        }

        // Decode value.
        $decoded = json_decode($data['availabilityconditionsjson']);
        if (!$decoded) {
            // This shouldn't be possible.
            throw new \coding_exception('Invalid JSON from availabilityconditionsjson field');
        }
        if (!empty($decoded->errors)) {
            $error = '';
            foreach ($decoded->errors as $stringinfo) {
                list ($component, $stringname) = explode(':', $stringinfo);
                if ($error !== '') {
                    $error .= ' ';
                }
                $error .= get_string($stringname, $component);
            }
            $errors['availabilityconditionsjson'] = $error;
        }
    }
public static function report_validation_errors(array $data, array &$errors) {
        // Empty value is allowed!
        if ($data['availabilityconditionsjson'] === '') {
            return;
        }

        // Decode value.
        $decoded = json_decode($data['availabilityconditionsjson']);
        if (!$decoded) {
            // This shouldn't be possible.
            throw new \coding_exception('Invalid JSON from availabilityconditionsjson field');
        }
        if (!empty($decoded->errors)) {
            $error = '';
            foreach ($decoded->errors as $stringinfo) {
                list ($component, $stringname) = explode(':', $stringinfo);
                if ($error !== '') {
                    $error .= ' ';
                }
                $error .= get_string($stringname, $component);
            }
            $errors['availabilityconditionsjson'] = $error;
        }
    }
public static function report_validation_errors ( array $ data , array & $ errors ) { // Empty value is allowed! if ( $ data [ 'availabilityconditionsjson' ] === '' ) { return ; } // Decode value. $ decoded = json_decode ( $ data [ 'availabilityconditionsjson' ] ) ; if ( ! $ decoded ) { // This shouldn't be possible. throw new \ coding_exception ( 'Invalid JSON from availabilityconditionsjson field' ) ; } if ( ! empty ( $ decoded -> errors ) ) { $ error = '' ; foreach ( $ decoded -> errors as $ stringinfo ) { list ( $ component , $ stringname ) = explode ( ':' , $ stringinfo ) ; if ( $ error !== '' ) { $ error .= ' ' ; } $ error .= get_string ( $ stringname , $ component ) ; } $ errors [ 'availabilityconditionsjson' ] = $ error ; } }
For use within forms, reports any validation errors from the availability
field.

@param array $data Form data fields
@param array $errors Error array
For use within forms reports any validation errors from the availability field .