MCPcopy Create free account
hub / github.com/biblius/validify / parse_custom_full

Function parse_custom_full

validify_derive/src/validate/parser.rs:261–295  ·  view source on GitHub ↗
(meta: &ParseNestedMeta)

Source from the content-addressed store, hash-verified

259}
260
261pub fn parse_custom_full(meta: &ParseNestedMeta) -> Result<Custom, syn::Error> {
262 let mut validation = Custom {
263 path: syn::Path {
264 leading_colon: None,
265 segments: Punctuated::new(),
266 },
267 code: None,
268 message: None,
269 };
270
271 meta.parse_nested_meta(|meta| {
272 if meta.path.is_ident("function") {
273 let content = meta.value()?;
274 match content.parse::<syn::Path>() {
275 Ok(path) => {
276 validation.path = path;
277 }
278 Err(_) => return Err(meta.error(
279 "custom value must be a path to a function that takes in the type of the field",
280 )),
281 }
282 return Ok(());
283 }
284
285 code_and_message!(validation, meta);
286
287 Err(meta.error("Unrecognized custom parameter, accepted are: path, code, message"))
288 })?;
289
290 if validation.path.segments.is_empty() {
291 abort!(meta.input.span(), "custom validation must contain a path")
292 }
293
294 Ok(validation)
295}
296
297pub fn parse_regex_full(meta: &ParseNestedMeta) -> Result<Regex, syn::Error> {
298 let mut validation = Regex {

Callers 1

parse_single_validationFunction · 0.85

Calls 1

is_emptyMethod · 0.80

Tested by

no test coverage detected