add config.value.mandatory()
This commit is contained in:
parent
814c8ca96b
commit
260cd77d55
|
@ -83,7 +83,7 @@ class TiramisuOptionOption:
|
|||
|
||||
def properties(self) -> List[str]:
|
||||
props = []
|
||||
model = self.model[self._path]
|
||||
model = self.model.get(self._path, {})
|
||||
if model.get('required'):
|
||||
#FIXME 'empty', 'needs_len'
|
||||
props.append('mandatory')
|
||||
|
@ -435,8 +435,7 @@ class ContextValue(_Value):
|
|||
self.form = form
|
||||
first = next(iter(schema.keys()))
|
||||
self.path = first.rsplit('.', 1)[0]
|
||||
schema = {'properties': schema}
|
||||
self.schema = schema
|
||||
self.schema = {'properties': schema}
|
||||
self.temp = temp
|
||||
|
||||
def __call__(self) -> TiramisuOptionValue:
|
||||
|
@ -448,6 +447,14 @@ class ContextValue(_Value):
|
|||
path,
|
||||
index)
|
||||
|
||||
def mandatory(self):
|
||||
# config.value.mandatory()
|
||||
for key, value in self.dict().items():
|
||||
if self.model.get(key, {}).get('required') and \
|
||||
value is None or \
|
||||
(self.schema.get('isMulti') and (None in value or '' in value)):
|
||||
yield key
|
||||
|
||||
|
||||
class Config:
|
||||
# config
|
||||
|
|
Loading…
Reference in New Issue