mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	docs: Remove recommendations of json_validator with check_string.
See #18035 for background.
This commit is contained in:
		@@ -415,7 +415,7 @@ annotation).
 | 
				
			|||||||
 def update_realm(
 | 
					 def update_realm(
 | 
				
			||||||
     request: HttpRequest,
 | 
					     request: HttpRequest,
 | 
				
			||||||
     user_profile: UserProfile,
 | 
					     user_profile: UserProfile,
 | 
				
			||||||
     name: Optional[str] = REQ(json_validator=check_string, default=None),
 | 
					     name: Optional[str] = REQ(str_validator=check_string, default=None),
 | 
				
			||||||
     # ...
 | 
					     # ...
 | 
				
			||||||
+    mandatory_topics: Optional[bool] = REQ(json_validator=check_bool, default=None),
 | 
					+    mandatory_topics: Optional[bool] = REQ(json_validator=check_bool, default=None),
 | 
				
			||||||
     # ...
 | 
					     # ...
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -194,6 +194,11 @@ REQ also helps us with request variable validation. For example:
 | 
				
			|||||||
  integer (`converter` differs from `json_validator` in that it does
 | 
					  integer (`converter` differs from `json_validator` in that it does
 | 
				
			||||||
  not automatically marshall the input from JSON).
 | 
					  not automatically marshall the input from JSON).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* Since there is no need to JSON-encode strings, usually simply
 | 
				
			||||||
 | 
					  `my_string=REQ()` is correct.  One can pass e.g.
 | 
				
			||||||
 | 
					  `str_validator=check_string_in(...)` where one wants to run a
 | 
				
			||||||
 | 
					  validator on the value of a string.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
See
 | 
					See
 | 
				
			||||||
[zerver/lib/validator.py](https://github.com/zulip/zulip/blob/master/zerver/lib/validator.py)
 | 
					[zerver/lib/validator.py](https://github.com/zulip/zulip/blob/master/zerver/lib/validator.py)
 | 
				
			||||||
for more validators and their documentation.
 | 
					for more validators and their documentation.
 | 
				
			||||||
@@ -261,7 +266,7 @@ For example, in [zerver/views/realm.py](https://github.com/zulip/zulip/blob/mast
 | 
				
			|||||||
@has_request_variables
 | 
					@has_request_variables
 | 
				
			||||||
def update_realm(
 | 
					def update_realm(
 | 
				
			||||||
    request: HttpRequest, user_profile: UserProfile,
 | 
					    request: HttpRequest, user_profile: UserProfile,
 | 
				
			||||||
    name: Optional[str]=REQ(json_validator=check_string, default=None),
 | 
					    name: Optional[str]=REQ(str_validator=check_string, default=None),
 | 
				
			||||||
    # ...
 | 
					    # ...
 | 
				
			||||||
):
 | 
					):
 | 
				
			||||||
    realm = user_profile.realm
 | 
					    realm = user_profile.realm
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user