-
Notifications
You must be signed in to change notification settings - Fork 78
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
Default "max" or "min" values? #647
Comments
This can probably be closed. I wrote my own property decorator to implement this. import { compose, RxwebValidators } from "@rxweb/reactive-form-validators";
export const number = (config?: { min?: number; max?: number }) => {
const min = config?.min ?? -9999999999999999.99;
const max = config?.max ?? 9999999999999999.99;
const validators = [
RxwebValidators.minNumber({ value: min }),
RxwebValidators.minNumber({ value: max }),
];
const validate = compose({ validators });
return (target: any, propertyKey: string) => {
validate(target, propertyKey);
};
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the problem statement?
Is it possible to set the max/min values for decorators from a global config level?
I ask because there are certain min/max values that must be followed depending on your back-end. For example, the minimum date in SQL Server is 1753-1-1. Instead of adding a min date validator with this value specifically, it would be nice if I could just add the minDate validator and have it default to this value. This could be extended to numbers as well if you wanted to have the default min-max to be within the integer range. Not sure what else we could apply this to (maybe validation messages).
Example:
The expected solution you would like
I'd like to be able to set a value from a global place. Preferably from an injector like
My class could then be
Package version
"@rxweb/reactive-form-validators": "^13.0.1",
The text was updated successfully, but these errors were encountered: