MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / check_item

Function check_item

pywebio/io_ctrl.py:283–302  ·  view source on GitHub ↗
(name, data, valid_func, preprocess_func, clear_invalid=False)

Source from the content-addressed store, hash-verified

281
282
283def check_item(name, data, valid_func, preprocess_func, clear_invalid=False):
284 try:
285 data = preprocess_func(data)
286 error_msg = valid_func(data)
287 except Exception as e:
288 logger.warning('Get %r in valid_func for name:"%s"', e, name)
289 from pywebio.session import info as session_info
290 error_msg = '字段内容不合法' if 'zh' in session_info.user_language else 'Your input is not valid'
291
292 if error_msg is not None:
293 send_msg('update_input', dict(target_name=name, attributes={
294 'valid_status': False,
295 'invalid_feedback': error_msg
296 }))
297 return False
298 elif clear_invalid:
299 send_msg('update_input', dict(target_name=name, attributes={
300 'valid_status': 0, # valid_status为0表示清空valid_status标志
301 }))
302 return True
303
304
305def trigger_onchange(event_data, onchange_funcs):

Callers 1

input_event_handleFunction · 0.70

Calls 2

preprocess_funcFunction · 0.85
send_msgFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…