public function getAttributeRules()
    {
        $result = [];
        $attributes = $this->getAttributesFromSchema();
        $casts = $this->getCasts();
        $casts_back = $this->getAttributesFromSchema('cast-back', true);
        $rules = $this->getAttributesFromSchema('rules', true);

        // Build full rule for each attribute.
        foreach ($attributes as $key) {
            $result[$key] = [];
        }

        // If any casts back are configured, replace the value found in casts.
        // Handy if we read integer values as datetime, but save back as an integer.
        $casts = array_merge($casts, $casts_back);

        // Build full rule for each attribute.
        foreach ($casts as $key => $cast_type) {
            $cast_validator = $this->parseCastToValidator($cast_type);

            if (!empty($cast_validator)) {
                $result[$key][] = $cast_validator;
            }

            if ($this->exists) {
                $result[$key][] = 'sometimes';
            }
        }

        // Assign specified rules.
        foreach ($rules as $key => $rule) {
            $result[$key][] = $rule;
        }

        unset($result[$this->getKeyName()]);

        foreach ($result as $key => $rules) {
            $result[$key] = implode('|', $rules);
        }

        return $result;
    }