-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NotEmptyCollection] to validate empty list/array #77
Comments
I suggest using a property like It should be defined like [AttributeUsage(AttributeTargets.Field)]
public class CollectionSize : Attribute
{
public int Min = 0;
public int Max = int.MaxValue;
} And used like [CollectionSize(Min = 1)] // Equivalent to [NotEmptyCollection]
public List<Transform> endOfBarrels;
[CollectionSize(Min = 1, Max = 10)] // Size must be between 1 and 10 inclusive
public List<Transform> endOfBarrels;
[CollectionSize(Max = 10)] // Can be empty but size has to be less than or equal 10
public List<Transform> endOfBarrels; |
@AliAlbarrak This is a much better idea. I think I'll put it into existing API, either |
ArraySize already exists, it hard sets the array size |
It can be like this:
Then, This at least can keep the compatibility with the old API |
Hi, this feature has been added to 3.3.8
For example:
[ArraySize(1, 3), ListDrawerSettings] public int[] oneToThreeWithSettings; |
That's so nice! Thanks! |
probably by design but would be nice ™
The text was updated successfully, but these errors were encountered: