# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/mxns/02_reqr.ipynb.

# %% auto 0
__all__ = ['RequiredMixin']

# %% ../../nbs/mxns/02_reqr.ipynb 6
import os, pathlib

# %% ../../nbs/mxns/02_reqr.ipynb 8
from typing import Callable, Optional

# %% ../../nbs/mxns/02_reqr.ipynb 10
from nlit import (REQUIRED, )

# %% ../../nbs/mxns/02_reqr.ipynb 12
#| export


# %% ../../nbs/mxns/02_reqr.ipynb 14
class RequiredMixin:
    required: bool = True
    aspec: tuple = (REQUIRED, )
    inherit_aspec: bool = True
    
    @property
    def optional(self) -> bool: return not self.required
    @optional.setter
    def optional(self, bval: bool): self.required = not bool(bval)

    def isvalid(self) -> bool:
        return self.exists() if self.required else True
