pydantic-numpy
                                
                                 pydantic-numpy copied to clipboard
                                
                                    pydantic-numpy copied to clipboard
                            
                            
                            
                        support shape as parameter
This comment in the original thread was restricting shape of the array. Please consider adding shape to pydantic-numpy (I don't have the fluency with generics to do it myself).
Yes, shape validation would be very helpful for me as well. Here's the syntax I would like:
shape is 2 by 3: shape=(2, 3)
constrain to any number of rows and 2 columns: shape=(None, 2)
constrain to any number of rows and 2 or 3 columns shape=((None, 2), (None, 3))
2 or 3-dimensional: shape=((None, None), (None, None, None))
@bendichter thanks for your suggestions. Maybe we can work around the missing shape parameter using typing.Annotated. See here https://stackoverflow.com/a/72585748/242594
Thanks for the pointer!
I can implement this in April for native pydantic-numpy support
That would be great!
This is now supported on pydantic-numpy ^3.0: https://github.com/caniko/pydantic-numpy